CommentLoad.php in Drupal 7 to 8/9 Module Upgrader 8
File
src/Plugin/DMU/Converter/Functions/CommentLoad.php
View source
<?php
namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
use Drupal\drupalmoduleupgrader\TargetInterface;
use Pharborist\Functions\FunctionCallNode;
use Pharborist\Objects\ClassMethodCallNode;
class CommentLoad extends FunctionCallModifier {
public function rewrite(FunctionCallNode $call, TargetInterface $target) {
$arguments = $call
->getArguments();
if (sizeof($arguments) == 2) {
$this
->buildFixMe('To reset the comment cache, use EntityStorageInterface::resetCache().')
->insertBefore($call);
}
return ClassMethodCallNode::create('\\Drupal', 'entityTypeManager')
->appendMethodCall('getStorage')
->appendArgument('comment')
->appendMethodCall('load')
->appendArgument(clone $arguments[0]);
}
}
Classes
Name |
Description |
CommentLoad |
Plugin annotation
@Converter(
id = "comment_load",
description = @Translation("Rewrites calls to comment_load()."),
fixme = @Translation("comment_load() is now EntityStorageInterface::load().")
) |