LoadMultiple.php in Drupal 7 to 8/9 Module Upgrader 8
File
src/Plugin/DMU/Converter/Functions/LoadMultiple.php
View source
<?php
namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
use Drupal\drupalmoduleupgrader\TargetInterface;
use Pharborist\Functions\FunctionCallNode;
use Pharborist\Objects\ClassMethodCallNode;
class LoadMultiple extends FunctionCallModifier {
public function rewrite(FunctionCallNode $call, TargetInterface $target) {
$arguments = $call
->getArguments();
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', 'entityTypeManager')
->appendMethodCall('getStorage')
->appendArgument($this->pluginDefinition['entity_type']);
if (sizeof($arguments) > 1) {
return $rewritten
->appendMethodCall('loadByProperties')
->appendArgument(clone $arguments[1]);
}
else {
return $rewritten
->appendMethodCall('loadMultiple')
->appendArgument(clone $arguments[0]);
}
}
}
Classes
Name |
Description |
LoadMultiple |
Plugin annotation
@Converter(
id = "_load_multiple",
deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions\LoadMultipleDeriver"
) |