annotate core/modules/migrate/src/ProcessPluginBase.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\migrate;
Chris@0 4
Chris@0 5 use Drupal\Core\Plugin\PluginBase;
Chris@0 6 use Drupal\migrate\Plugin\MigrateProcessInterface;
Chris@0 7
Chris@0 8 /**
Chris@0 9 * The base class for all migrate process plugins.
Chris@0 10 *
Chris@0 11 * Migrate process plugins are taking a value and transform them. For example,
Chris@0 12 * transform a human provided name into a machine name, look up an identifier
Chris@0 13 * in a previous migration and so on.
Chris@0 14 *
Chris@0 15 * @see https://www.drupal.org/node/2129651
Chris@0 16 * @see \Drupal\migrate\Plugin\MigratePluginManager
Chris@0 17 * @see \Drupal\migrate\Plugin\MigrateProcessInterface
Chris@0 18 * @see \Drupal\migrate\Annotation\MigrateProcessPlugin
Chris@0 19 * @see plugin_api
Chris@0 20 *
Chris@0 21 * @ingroup migration
Chris@0 22 */
Chris@0 23 abstract class ProcessPluginBase extends PluginBase implements MigrateProcessInterface {
Chris@0 24
Chris@0 25 /**
Chris@0 26 * {@inheritdoc}
Chris@0 27 */
Chris@0 28 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
Chris@0 29 // Do not call this method from children.
Chris@0 30 if (isset($this->configuration['method'])) {
Chris@0 31 if (method_exists($this, $this->configuration['method'])) {
Chris@0 32 return $this->{$this->configuration['method']}($value, $migrate_executable, $row, $destination_property);
Chris@0 33 }
Chris@0 34 throw new \BadMethodCallException(sprintf('The %s method does not exist in the %s plugin.', $this->configuration['method'], $this->pluginId));
Chris@0 35 }
Chris@0 36 else {
Chris@0 37 throw new \BadMethodCallException(sprintf('The "method" key in the plugin configuration must to be set for the %s plugin.', $this->pluginId));
Chris@0 38 }
Chris@0 39 }
Chris@0 40
Chris@0 41 /**
Chris@0 42 * {@inheritdoc}
Chris@0 43 */
Chris@0 44 public function multiple() {
Chris@0 45 return FALSE;
Chris@0 46 }
Chris@0 47
Chris@0 48 }