3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Objects\ClassMethodCallNode;
8 use Pharborist\Types\ArrayNode;
12 * id = "module_invoke",
13 * description = @Translation("Rewrites calls to module_invoke().")
16 class ModuleInvoke extends FunctionCallModifier {
21 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
22 $arguments = $call->getArguments()->toArray();
24 $invoke = ClassMethodCallNode::create('\Drupal', 'moduleHandler')
25 ->appendMethodCall('invoke')
26 ->appendArgument(array_shift($arguments)->remove())
27 ->appendArgument(array_shift($arguments)->remove());
30 $invoke->appendArgument(ArrayNode::create($arguments));