diff --git a/core/modules/migrate/src/Plugin/migrate/process/Download.php b/core/modules/migrate/src/Plugin/migrate/process/Download.php index cc5ed85..8773f39 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Download.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Download.php @@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\Row; use GuzzleHttp\Client; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -26,6 +27,8 @@ * - 'use existing' - Do nothing and return FALSE. * - guzzle_options: (optional) * @link http://docs.guzzlephp.org/en/latest/request-options.html Array of request options for Guzzle. @endlink + * - skip_process_on_failure: (optional) Boolean, if TRUE, we throw a + * MigrateSkipRowException, if FALSE, throw a MigrateException exception. * * Examples: * @@ -152,7 +155,12 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $this->httpClient->get($source, $this->configuration['guzzle_options']); } catch (\Exception $e) { - throw new MigrateException("{$e->getMessage()} ($source)"); + if (empty($this->configuration['skip_process_on_failure'])) { + throw new MigrateException("{$e->getMessage()} ($source)"); + } + else { + throw new MigrateSkipRowException("{$e->getMessage()} ($source)"); + } } return $final_destination; diff --git a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php index 88f2212..40e05a4 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php +++ b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php @@ -8,6 +8,7 @@ use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -31,6 +32,8 @@ * - 'rename' - Append _{incrementing number} until the filename is * unique. * - 'use existing' - Do nothing and return FALSE. + * - skip_process_on_failure: (optional) Boolean, if TRUE, we throw a + * MigrateSkipRowException, if FALSE, throw a MigrateException exception. * * Examples: * @@ -153,7 +156,12 @@ public function transform($value, MigrateExecutableInterface $migrate_executable if ($final_destination) { return $final_destination; } - throw new MigrateException("File $source could not be copied to $destination"); + if (empty($this->configuration['skip_process_on_failure'])) { + throw new MigrateException("File $source could not be copied to $destination"); + } + else { + throw new MigrateSkipRowException("File '$source' does not exist"); + } } /**