DB.php in Drupal 7 to 8/9 Module Upgrader 8
File
src/Plugin/DMU/Analyzer/DB.php
View source
<?php
namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer;
use Drupal\drupalmoduleupgrader\AnalyzerBase;
use Drupal\drupalmoduleupgrader\TargetInterface;
use Pharborist\Functions\FunctionCallNode;
use Pharborist\Types\StringNode;
class DB extends AnalyzerBase {
protected static $forbiddenTables = [
'variable',
];
public function analyze(TargetInterface $target) {
$function_calls = $target
->getIndexer('function_call')
->get($this->pluginDefinition['function'] ?: $this
->getPluginId())
->filter(function (FunctionCallNode $function_call) {
$arguments = $function_call
->getArguments();
return $arguments[0] instanceof StringNode && in_array($arguments[0]
->toValue(), self::$forbiddenTables);
});
$issues = [];
if ($function_calls
->count() > 0) {
$issue = $this
->buildIssue($target);
$function_calls
->each(function (FunctionCallNode $function_call) use ($issue) {
$issue
->addViolation($function_call, $this);
});
$issues[] = $issue;
}
return $issues;
}
}
Classes
Name |
Description |
DB |
Plugin annotation
@Analyzer(
id = "_db",
message = @Translation("Certain database tables have been removed."),
tags = {
"category" = { "db" }
},
deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\DBDeriver"
) |