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\Objects\ObjectMethodCallNode;
9 use Pharborist\Variables\VariableNode;
14 * description = @Translation("Rewrites calls to user_access().")
17 class UserAccess extends FunctionCallModifier {
22 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
23 $arguments = $call->getArguments();
25 if (isset($arguments[1]) && $arguments[1] instanceof VariableNode) {
26 $rewritten = ObjectMethodCallNode::create(clone $arguments[1], 'hasPermission');
29 $rewritten = ClassMethodCallNode::create('\Drupal', 'currentUser')->appendMethodCall('hasPermission');
32 return $rewritten->appendArgument(clone $arguments[0]);