Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / FormExecuteHandlers.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
4
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Objects\ClassMethodCallNode;
8 use Pharborist\Types\StringNode;
9
10 /**
11  * @Converter(
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.")
15  * )
16  */
17 class FormExecuteHandlers extends FunctionCallModifier {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function rewrite(FunctionCallNode $call, TargetInterface $target) {
23     $arguments = $call->getArguments();
24
25     if ($arguments[0] instanceof StringNode) {
26       $handler_type = $arguments[0]->toValue();
27
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]);
33       }
34     }
35   }
36
37 }