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