You are here

public function DB::analyze in Drupal 7 to 8/9 Module Upgrader 8

Analyzes a target module and flags any issues found.

Parameters

TargetInterface $target: The target module.

Return value

\Drupal\drupalmoduleupgrader\IssueInterface[]

Overrides AnalyzerInterface::analyze

File

src/Plugin/DMU/Analyzer/DB.php, line 32

Class

DB
Plugin annotation @Analyzer( id = "_db", message = @Translation("Certain database tables have been removed."), tags = { "category" = { "db" } }, deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\DBDeriver" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer

Code

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;
}