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%2FLoadMultiple.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FConverter%2FFunctions%2FLoadMultiple.php;h=57d2915e9041d0c5432b7f286411c0b803eb247c;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/LoadMultiple.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/LoadMultiple.php new file mode 100644 index 000000000..57d2915e9 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/LoadMultiple.php @@ -0,0 +1,53 @@ +getArguments(); + + // If there were three arguments, the call is affecting the internal + // entity 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) { + $variables = [ + '!entity_type' => $this->pluginDefinition['entity_type'], + ]; + $this->buildFixMe('To reset the !entity_type cache, use EntityStorageInterface::resetCache().', $variables)->insertBefore($call); + } + + $rewritten = ClassMethodCallNode::create('\Drupal', 'entityManager') + ->appendMethodCall('getStorage') + ->appendArgument($this->pluginDefinition['entity_type']); + + // If there's more than one argument, conditions were passed (not a + // recommended practice, but modules might have done it anyway), in which + // case we need to use loadByProperties(). Otherwise, loadMultiple(). + if (sizeof($arguments) > 1) { + return $rewritten + ->appendMethodCall('loadByProperties') + ->appendArgument(clone $arguments[1]); + } + else { + return $rewritten + ->appendMethodCall('loadMultiple') + ->appendArgument(clone $arguments[0]); + } + } + +}