/**
* {@inheritdoc}
*/
- public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
- if (is_callable($this->configuration['callable'])) {
- $value = call_user_func($this->configuration['callable'], $value);
+ public function __construct(array $configuration, $plugin_id, $plugin_definition) {
+ if (!isset($configuration['callable'])) {
+ throw new \InvalidArgumentException('The "callable" must be set.');
+ }
+ elseif (!is_callable($configuration['callable'])) {
+ throw new \InvalidArgumentException('The "callable" must be a valid function or method.');
}
- return $value;
+ parent::__construct($configuration, $plugin_id, $plugin_definition);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+ return call_user_func($this->configuration['callable'], $value);
}
}