Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / FieldViewField.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\ObjectMethodCallNode;
8 use Pharborist\Parser;
9 use Pharborist\Types\StringNode;
10
11 /**
12  * @Converter(
13  *  id = "field_view_field",
14  *  description = @Translation("Rewrites calls to field_view_field().")
15  * )
16  */
17 class FieldViewField extends FunctionCallModifier {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function rewrite(FunctionCallNode $call, TargetInterface $target) {
23     $arguments = $call->getArguments();
24
25     $property = $arguments[2] instanceof StringNode ? $arguments[2]->toValue() : clone $arguments[2];
26     $rewritten = ObjectMethodCallNode::create(Parser::parseExpression($arguments[1] . '->' . $property), 'view');
27
28     if (sizeof($arguments) >= 4) {
29       $rewritten->appendArgument(clone $arguments[3]);
30     }
31
32     return $rewritten;
33   }
34
35 }