3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Objects\ClassMethodCallNode;
9 use Pharborist\Types\StringNode;
14 * description = @Translation("Rewrites calls to l()."),
15 * fixme = @Translation("l() expects a Url object, created from a route name or external URI."),
16 * dependencies = { "router.route_provider" }
24 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
25 $arguments = $call->getArguments();
26 if ($arguments[1] instanceof StringNode) {
27 // Create a call to url() and let the parent class rewrite it like normal,
28 // so we don't have to duplicate that code.
29 $url = Parser::parseSnippet('url(' . $arguments[1] . ');')->firstChild();
30 $url_rewritten = parent::rewrite($url, $target);
32 return ClassMethodCallNode::create('\Drupal', 'l')
33 ->appendArgument($arguments[0])
34 ->appendArgument($url_rewritten);