3 namespace Drupal\migrate\Plugin\migrate\process;
5 use Drupal\migrate\MigrateExecutableInterface;
6 use Drupal\migrate\ProcessPluginBase;
7 use Drupal\migrate\Row;
10 * Passes the source value to a callback.
12 * The callback process plugin allows simple processing of the value, such as
13 * strtolower(). The callable takes the source value as the single mandatory
14 * argument. No additional arguments can be passed to the callback.
16 * Available configuration keys:
17 * - callable: The name of the callable method.
25 * callable: strtolower
26 * source: source_field
29 * An example where the callable is a static method in a class:
36 * - '\Drupal\Component\Utility\Unicode'
38 * source: source_field
41 * @see \Drupal\migrate\Plugin\MigrateProcessInterface
43 * @MigrateProcessPlugin(
47 class Callback extends ProcessPluginBase {
52 public function __construct(array $configuration, $plugin_id, $plugin_definition) {
53 if (!isset($configuration['callable'])) {
54 throw new \InvalidArgumentException('The "callable" must be set.');
56 elseif (!is_callable($configuration['callable'])) {
57 throw new \InvalidArgumentException('The "callable" must be a valid function or method.');
59 parent::__construct($configuration, $plugin_id, $plugin_definition);
65 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
66 return call_user_func($this->configuration['callable'], $value);