Now the files migration does not die when a file is missing.

It now just ignore that file and continue with the rest.
This commit is contained in:
David Valdez 2019-08-30 12:54:44 -05:00
parent e62dcf96f4
commit d7e81b4703
2 changed files with 42 additions and 3 deletions

View file

@ -0,0 +1,39 @@
<?php
namespace Drupal\geo_upgrade\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* @MigrateProcessPlugin(
* id = "geo_file_exists"
* )
*/
class FileExists extends ProcessPluginBase {
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($source, $destination) = $value;
// Ensure the source file exists.
if (!file_exists($source)) {
throw new MigrateSkipRowException("File '$source' does not exist");
}
return $value;
}
}