X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FConverter%2FFunctions%2FNodeLoad.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FConverter%2FFunctions%2FNodeLoad.php;h=405b0ea110aab187df2c22909f5fcd32840f7d1b;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/NodeLoad.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/NodeLoad.php new file mode 100644 index 000000000..405b0ea11 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/NodeLoad.php @@ -0,0 +1,50 @@ +getArguments(); + + // If there were three arguments, the call is affecting the internal + // node_load() cache. Unfortunately, it's pretty much impossible to + // reliably determine whether or not they wanted to reset the cache, + // so let's just leave a FIXME. + if (sizeof($arguments) == 3) { + $this->buildFixMe('To reset the node cache, use EntityStorageInterface::resetCache().')->insertBefore($call); + } + + $rewritten = ClassMethodCallNode::create('\Drupal', 'entityManager') + ->appendMethodCall('getStorage') + ->appendArgument('node'); + + // If there's more than one argument, a revision ID was passed, which + // means we call loadRevision($nid). Otherwise, call load($nid). + if (sizeof($arguments) > 1) { + return $rewritten + ->appendMethodCall('loadRevision') + ->appendArgument(clone $arguments[1]); + } + else { + return $rewritten + ->appendMethodCall('load') + ->appendArgument(clone $arguments[0]); + } + } + +}