3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Objects\ClassMethodCallNode;
12 * description = @Translation("Rewrites calls to user_load()."),
13 * fixme = @Translation("user_load() is now EntityStorageInterface::load().")
16 class UserLoad extends FunctionCallModifier {
21 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
22 $arguments = $call->getArguments();
24 // If there were three arguments, the call is affecting the internal
25 // user_load() cache. Unfortunately, it's pretty much impossible to
26 // reliably determine whether or not they wanted to reset the cache,
27 // so let's just leave a FIXME.
28 if (sizeof($arguments) == 2) {
29 $this->buildFixMe('To reset the user cache, use EntityStorageInterface::resetCache().')->insertBefore($call);
32 return ClassMethodCallNode::create('\Drupal', 'entityManager')
33 ->appendMethodCall('getStorage')
34 ->appendArgument('user')
35 ->appendMethodCall('load')
36 ->appendArgument(clone $arguments[0]);