3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Objects\ObjectMethodCallNode;
9 use Pharborist\Types\StringNode;
13 * id = "field_view_field",
14 * description = @Translation("Rewrites calls to field_view_field().")
17 class FieldViewField extends FunctionCallModifier {
22 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
23 $arguments = $call->getArguments();
25 $property = $arguments[2] instanceof StringNode ? $arguments[2]->toValue() : clone $arguments[2];
26 $rewritten = ObjectMethodCallNode::create(Parser::parseExpression($arguments[1] . '->' . $property), 'view');
28 if (sizeof($arguments) >= 4) {
29 $rewritten->appendArgument(clone $arguments[3]);