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\StringNode;
12 * id = "form_execute_handlers",
13 * description = @Translation("Rewrites calls to form_execute_handlers()."),
14 * fixme = @Translation("form_execute_handlers() has been split into the executeValidateHandlers() and executeSubmitHandlers() methods of the form builder service.")
17 class FormExecuteHandlers extends FunctionCallModifier {
22 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
23 $arguments = $call->getArguments();
25 if ($arguments[0] instanceof StringNode) {
26 $handler_type = $arguments[0]->toValue();
28 if ($handler_type == 'validate' || $handler_type == 'submit') {
29 return ClassMethodCallNode::create('\Drupal', 'formBuilder')
30 ->appendMethodCall('execute' . ucFirst($handler_type) . 'Handlers')
31 ->appendArgument(clone $arguments[1])
32 ->appendArgument(clone $arguments[2]);