DbQuery.php in Drupal 7 to 8/9 Module Upgrader 8
File
src/Plugin/DMU/Converter/Functions/DbQuery.php
View source
<?php
namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
use Drupal\drupalmoduleupgrader\TargetInterface;
use Pharborist\Functions\FunctionCallNode;
use Pharborist\Objects\ClassMethodCallNode;
class DbQuery extends FunctionCallModifier {
public function rewrite(FunctionCallNode $call, TargetInterface $target) {
$arguments = $call
->getArguments();
$object = ClassMethodCallNode::create('\\Drupal', 'database')
->appendMethodCall('query')
->appendArgument(clone $arguments[0]);
if (!empty($arguments[1])) {
$object
->appendArgument(clone $arguments[1]);
}
if (!empty($arguments[2])) {
$object
->appendArgument(clone $arguments[0]);
}
return $object;
}
}
Classes
Name |
Description |
DbQuery |
Plugin annotation
@Converter(
id = "db_query",
description = @Translation("Rewrites calls to db_query()."),
) |