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