Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / ModuleInvoke.php
diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/ModuleInvoke.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/ModuleInvoke.php
new file mode 100644 (file)
index 0000000..39acaa3
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
+
+use Drupal\drupalmoduleupgrader\TargetInterface;
+use Pharborist\Functions\FunctionCallNode;
+use Pharborist\Objects\ClassMethodCallNode;
+use Pharborist\Types\ArrayNode;
+
+/**
+ * @Converter(
+ *  id = "module_invoke",
+ *  description = @Translation("Rewrites calls to module_invoke().")
+ * )
+ */
+class ModuleInvoke extends FunctionCallModifier {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function rewrite(FunctionCallNode $call, TargetInterface $target) {
+    $arguments = $call->getArguments()->toArray();
+
+    $invoke = ClassMethodCallNode::create('\Drupal', 'moduleHandler')
+      ->appendMethodCall('invoke')
+      ->appendArgument(array_shift($arguments)->remove())
+      ->appendArgument(array_shift($arguments)->remove());
+
+    if ($arguments) {
+      $invoke->appendArgument(ArrayNode::create($arguments));
+    }
+
+    return $invoke;
+  }
+
+}