Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / migrate / src / Plugin / migrate / process / Callback.php
index 8721899f46367e90939bbfde70a73c74d21972b9..0d955c7f99dfaa9ce1334a88f6d998d463d3ec31 100644 (file)
@@ -49,11 +49,21 @@ class Callback extends ProcessPluginBase {
   /**
    * {@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);
   }
 
 }