PageRenderTime 46ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/core/modules/migrate/src/ProcessPluginBase.php

http://github.com/drupal/drupal
PHP | 48 lines | 20 code | 6 blank | 22 comment | 3 complexity | 6c7c2ae1c366b4a855cf7a7684214335 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. namespace Drupal\migrate;
  3. use Drupal\Core\Plugin\PluginBase;
  4. use Drupal\migrate\Plugin\MigrateProcessInterface;
  5. /**
  6. * The base class for all migrate process plugins.
  7. *
  8. * Migrate process plugins are taking a value and transform them. For example,
  9. * transform a human provided name into a machine name, look up an identifier
  10. * in a previous migration and so on.
  11. *
  12. * @see https://www.drupal.org/node/2129651
  13. * @see \Drupal\migrate\Plugin\MigratePluginManager
  14. * @see \Drupal\migrate\Plugin\MigrateProcessInterface
  15. * @see \Drupal\migrate\Annotation\MigrateProcessPlugin
  16. * @see plugin_api
  17. *
  18. * @ingroup migration
  19. */
  20. abstract class ProcessPluginBase extends PluginBase implements MigrateProcessInterface {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  25. // Do not call this method from children.
  26. if (isset($this->configuration['method'])) {
  27. if (method_exists($this, $this->configuration['method'])) {
  28. return $this->{$this->configuration['method']}($value, $migrate_executable, $row, $destination_property);
  29. }
  30. throw new \BadMethodCallException(sprintf('The %s method does not exist in the %s plugin.', $this->configuration['method'], $this->pluginId));
  31. }
  32. else {
  33. throw new \BadMethodCallException(sprintf('The "method" key in the plugin configuration must to be set for the %s plugin.', $this->pluginId));
  34. }
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function multiple() {
  40. return FALSE;
  41. }
  42. }