diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index a68b087..51c2561 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -16,7 +16,7 @@ /** * Defines a migrate executable class. */ -class MigrateExecutable { +class MigrateExecutable implements MigrateExecutableInterface { use StringTranslationTrait; /** @@ -222,7 +222,7 @@ public function __construct(MigrationInterface $migration, MigrateMessageInterfa * @return \Drupal\migrate\Source * The source. */ - public function getSource() { + protected function getSource() { if (!isset($this->source)) { $this->source = new Source($this->migration, $this); } @@ -230,7 +230,7 @@ public function getSource() { } /** - * Performs an import operation - migrate items from source to destination. + * {@inheritdoc} */ public function import() { // Knock off migration if the requirements haven't been met. @@ -347,22 +347,7 @@ public function import() { } /** - * Processes a row. - * - * @param \Drupal\migrate\Row $row - * The $row to be processed. - * @param array $process - * (optional) A process pipeline configuration. If not set, the top level - * process configuration in the migration entity is used. - * @param mixed $value - * (optional) Initial value of the pipeline for the first destination. - * Usually setting this is not necessary as $process typically starts with - * a 'get'. This is useful only when the $process contains a single - * destination and needs to access a value outside of the source. See - * \Drupal\migrate\Plugin\migrate\process\Iterator::transformKey for an - * example. - * - * @throws \Drupal\migrate\MigrateException + * {@inheritdoc} */ public function processRow(Row $row, array $process = NULL, $value = NULL) { foreach ($this->migration->getProcessPlugins($process) as $destination => $plugins) { @@ -444,10 +429,7 @@ protected function timeOptionExceeded() { } /** - * Returns the time limit. - * - * @return null|int - * The time limit, NULL if no limit or if the units were not in seconds. + * {@inheritdoc} */ public function getTimeLimit() { $limit = $this->limit; @@ -460,31 +442,21 @@ public function getTimeLimit() { } /** - * Passes messages through to the map class. - * - * @param string $message - * The message to record. - * @param int $level - * (optional) Message severity (defaults to MESSAGE_ERROR). + * {@inheritdoc} */ public function saveMessage($message, $level = MigrationInterface::MESSAGE_ERROR) { $this->migration->getIdMap()->saveMessage($this->sourceIdValues, $message, $level); } /** - * Queues messages to be later saved through the map class. - * - * @param string $message - * The message to record. - * @param int $level - * (optional) Message severity (defaults to MESSAGE_ERROR). + * {@inheritdoc} */ public function queueMessage($message, $level = MigrationInterface::MESSAGE_ERROR) { $this->queuedMessages[] = array('message' => $message, 'level' => $level); } /** - * Saves any messages we've queued up to the message table. + * {@inheritdoc} */ public function saveQueuedMessages() { foreach ($this->queuedMessages as $queued_message) { @@ -641,7 +613,7 @@ protected function getTimeElapsed() { * (optional) Whether to save the message in the migration's mapping table. * Set to FALSE in contexts where this doesn't make sense. */ - public function handleException(\Exception $exception, $save = TRUE) { + protected function handleException(\Exception $exception, $save = TRUE) { $result = Error::decodeException($exception); $message = $result['!message'] . ' (' . $result['%file'] . ':' . $result['%line'] . ')'; if ($save) { diff --git a/core/modules/migrate/src/MigrateExecutableInterface.php b/core/modules/migrate/src/MigrateExecutableInterface.php new file mode 100644 index 0000000..4a362fe --- /dev/null +++ b/core/modules/migrate/src/MigrateExecutableInterface.php @@ -0,0 +1,71 @@ +configuration['callable'])) { $value = call_user_func($this->configuration['callable'], $value); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Concat.php b/core/modules/migrate/src/Plugin/migrate/process/Concat.php index 4296057..44651d2 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Concat.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Concat.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\migrate\MigrateException; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; @@ -28,7 +28,7 @@ class Concat extends ProcessPluginBase { * * Concatenates the strings in the current value. */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (is_array($value)) { $delimiter = isset($this->configuration['delimiter']) ? $this->configuration['delimiter'] : ''; return implode($delimiter, $value); diff --git a/core/modules/migrate/src/Plugin/migrate/process/DedupeBase.php b/core/modules/migrate/src/Plugin/migrate/process/DedupeBase.php index d4d257e..8970bf8 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/DedupeBase.php +++ b/core/modules/migrate/src/Plugin/migrate/process/DedupeBase.php @@ -8,7 +8,7 @@ namespace Drupal\migrate\Plugin\migrate\process; use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; use Drupal\migrate\MigrateException; use Drupal\Component\Utility\Unicode; @@ -26,7 +26,7 @@ /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $i = 1; $postfix = isset($this->configuration['postfix']) ? $this->configuration['postfix'] : ''; $start = isset($this->configuration['start']) ? $this->configuration['start'] : 0; diff --git a/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php b/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php index 1758e52..1725818 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php +++ b/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php @@ -8,7 +8,7 @@ namespace Drupal\migrate\Plugin\migrate\process; use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; @@ -24,7 +24,7 @@ class DefaultValue extends ProcessPluginBase { /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (!empty($this->configuration['strict'])) { return isset($value) ? $value : $this->configuration['default_value']; } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Extract.php b/core/modules/migrate/src/Plugin/migrate/process/Extract.php index 4ec792b..72a2715 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Extract.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Extract.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateException; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; /** @@ -27,7 +27,7 @@ class Extract extends ProcessPluginBase { /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (!is_array($value)) { throw new MigrateException('Input should be an array.'); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Flatten.php b/core/modules/migrate/src/Plugin/migrate/process/Flatten.php index fd4cc46..f841ee7 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Flatten.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Flatten.php @@ -6,7 +6,7 @@ */ namespace Drupal\migrate\Plugin\migrate\process; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; @@ -31,7 +31,7 @@ class Flatten extends ProcessPluginBase { * * For example, array(array(1, 2, array(3, 4))) becomes array(1, 2, 3, 4). */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { return iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($value)), FALSE); } } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Get.php b/core/modules/migrate/src/Plugin/migrate/process/Get.php index 85da630..8355ad4 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Get.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Get.php @@ -8,7 +8,7 @@ namespace Drupal\migrate\Plugin\migrate\process; use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; /** @@ -28,7 +28,7 @@ class Get extends ProcessPluginBase { /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $source = $this->configuration['source']; $properties = is_string($source) ? array($source) : $source; $return = array(); diff --git a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php index f0bfdef..01bbd73 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php @@ -8,7 +8,7 @@ namespace Drupal\migrate\Plugin\migrate\process; use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; /** @@ -26,7 +26,7 @@ class Iterator extends ProcessPluginBase { /** * Runs a process pipeline on each destination property per list item. */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $return = array(); foreach ($value as $key => $new_value) { $new_row = new Row($new_value, array()); @@ -45,7 +45,7 @@ public function transform($value, MigrateExecutable $migrate_executable, Row $ro * * @param string|int $key * The current key. - * @param \Drupal\migrate\MigrateExecutable $migrate_executable + * @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable * The migrate executable helper class. * @param \Drupal\migrate\Row $row * The current row after processing. @@ -53,7 +53,7 @@ public function transform($value, MigrateExecutable $migrate_executable, Row $ro * @return mixed * The transformed key. */ - protected function transformKey($key, MigrateExecutable $migrate_executable, Row $row) { + protected function transformKey($key, MigrateExecutableInterface $migrate_executable, Row $row) { $process = array('key' => $this->configuration['key']); $migrate_executable->processRow($row, $process, $key); return $row->getDestinationProperty('key'); diff --git a/core/modules/migrate/src/Plugin/migrate/process/MachineName.php b/core/modules/migrate/src/Plugin/migrate/process/MachineName.php index d549267..f103b64 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/MachineName.php +++ b/core/modules/migrate/src/Plugin/migrate/process/MachineName.php @@ -9,7 +9,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; /** @@ -33,7 +33,7 @@ class MachineName extends ProcessPluginBase { /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $new_value = $this->getTransliteration()->transliterate($value, LanguageInterface::LANGCODE_DEFAULT, '_'); $new_value = strtolower($new_value); $new_value = preg_replace('/[^a-z0-9_]+/', '_', $new_value); diff --git a/core/modules/migrate/src/Plugin/migrate/process/Migration.php b/core/modules/migrate/src/Plugin/migrate/process/Migration.php index 64dd74f..df709e3 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Migration.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Migration.php @@ -17,7 +17,7 @@ use Drupal\migrate\Plugin\MigratePluginManager; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Entity\MigrationInterface; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -67,7 +67,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $migration_ids = $this->configuration['migration']; if (!is_array($migration_ids)) { $migration_ids = array($migration_ids); diff --git a/core/modules/migrate/src/Plugin/migrate/process/Route.php b/core/modules/migrate/src/Plugin/migrate/process/Route.php index 1e76def..d4cd813 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Route.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Route.php @@ -10,7 +10,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\migrate\Entity\MigrationInterface; use Drupal\Core\Path\PathValidatorInterface; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; @@ -52,7 +52,7 @@ public static function create(ContainerInterface $container, array $configuratio * * Set the destination route information based on the source link_path. */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { list($link_path, $options) = $value; $extracted = $this->pathValidator->getUrlIfValidWithoutAccessCheck($link_path); $route = array(); diff --git a/core/modules/migrate/src/Plugin/migrate/process/SkipProcessOnEmpty.php b/core/modules/migrate/src/Plugin/migrate/process/SkipProcessOnEmpty.php index 6a8f79c0..3713148 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/SkipProcessOnEmpty.php +++ b/core/modules/migrate/src/Plugin/migrate/process/SkipProcessOnEmpty.php @@ -7,7 +7,7 @@ namespace Drupal\migrate\Plugin\migrate\process; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateSkipProcessException; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; @@ -26,7 +26,7 @@ class SkipProcessOnEmpty extends ProcessPluginBase { * * Skip the rest of the processing on 0. */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (!$value) { throw new MigrateSkipProcessException(); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/SkipRowIfNotSet.php b/core/modules/migrate/src/Plugin/migrate/process/SkipRowIfNotSet.php index 4912141..2fa46f2 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/SkipRowIfNotSet.php +++ b/core/modules/migrate/src/Plugin/migrate/process/SkipRowIfNotSet.php @@ -8,7 +8,7 @@ namespace Drupal\migrate\Plugin\migrate\process; use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; use Drupal\migrate\MigrateSkipRowException; @@ -25,7 +25,7 @@ class SkipRowIfNotSet extends ProcessPluginBase { /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (!isset($value[$this->configuration['index']])) { throw new MigrateSkipRowException(); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/SkipRowOnEmpty.php b/core/modules/migrate/src/Plugin/migrate/process/SkipRowOnEmpty.php index 156dd33..227cbe7 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/SkipRowOnEmpty.php +++ b/core/modules/migrate/src/Plugin/migrate/process/SkipRowOnEmpty.php @@ -8,7 +8,7 @@ namespace Drupal\migrate\Plugin\migrate\process; use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; use Drupal\migrate\MigrateSkipRowException; @@ -24,7 +24,7 @@ class SkipRowOnEmpty extends ProcessPluginBase { /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (!$value) { throw new MigrateSkipRowException(); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php index e800819..bac2381 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php +++ b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateException; -use Drupal\migrate\MigrateExecutable; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; use Drupal\migrate\MigrateSkipRowException; @@ -28,7 +28,7 @@ class StaticMap extends ProcessPluginBase { /** * {@inheritdoc} */ - public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $new_value = $value; if (is_array($value)) { if (!$value) { diff --git a/core/modules/migrate/src/Source.php b/core/modules/migrate/src/Source.php index be4368b..ca2fe70 100644 --- a/core/modules/migrate/src/Source.php +++ b/core/modules/migrate/src/Source.php @@ -199,10 +199,10 @@ public function count($refresh = FALSE) { * * @param \Drupal\migrate\Entity\MigrationInterface $migration * The migration entity. - * @param \Drupal\migrate\MigrateExecutable $migrate_executable + * @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable * The migration executable. */ - public function __construct(MigrationInterface $migration, MigrateExecutable $migrate_executable) { + public function __construct(MigrationInterface $migration, MigrateExecutableInterface $migrate_executable) { $this->migration = $migration; $this->migrateExecutable = $migrate_executable; $configuration = $migration->get('source');