You are here

public function FlagHook::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/FlagHook.php, line 19

Class

FlagHook
Plugin annotation @Analyzer( id = "_flag_hook", deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\FlagHookDeriver" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer

Code

public function analyze(TargetInterface $target) {
  $hook = 'hook_' . $this->pluginDefinition['hook'];
  $indexer = $target
    ->getIndexer('function');
  if ($indexer
    ->has($hook)) {
    return [
      $this
        ->buildIssue($target)
        ->addViolation($indexer
        ->get($hook), $this),
    ];
  }
  else {
    return [];
  }
}