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:
parent
e62dcf96f4
commit
d7e81b4703
2 changed files with 42 additions and 3 deletions
|
@ -9,7 +9,7 @@ source:
|
||||||
plugin: d7_file
|
plugin: d7_file
|
||||||
scheme: public
|
scheme: public
|
||||||
constants:
|
constants:
|
||||||
source_base_path: '/var/www/html/d7/'
|
source_base_path: '../d7/'
|
||||||
process:
|
process:
|
||||||
fid:
|
fid:
|
||||||
-
|
-
|
||||||
|
@ -29,11 +29,11 @@ process:
|
||||||
-
|
-
|
||||||
plugin: urlencode
|
plugin: urlencode
|
||||||
uri:
|
uri:
|
||||||
-
|
- plugin: geo_file_exists
|
||||||
plugin: file_copy
|
|
||||||
source:
|
source:
|
||||||
- '@source_full_path'
|
- '@source_full_path'
|
||||||
- uri
|
- uri
|
||||||
|
- plugin: file_copy
|
||||||
filemime:
|
filemime:
|
||||||
-
|
-
|
||||||
plugin: get
|
plugin: get
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue