3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer;
5 use Drupal\drupalmoduleupgrader\AnalyzerBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
10 * id = "hook_permission",
11 * description = @Translation("Analyzes implementations of hook_permission()."),
14 * "url" = "https://www.drupal.org/node/2311427",
15 * "title" = @Translation("Defining permissions in `MODULE.permissions.yml`")
19 * "category" = { "system", "user" },
20 * "error_level" = "warning"
22 * hook = "hook_permission",
23 * message = @Translation("Static permissions are now defined in `MODULE.permissions.yml`.")
26 class HookPermission extends AnalyzerBase {
31 public function analyze(TargetInterface $target) {
33 $indexer = $target->getIndexer('function');
35 if ($indexer->hasExecutable('hook_permission')) {
38 ->addViolation($indexer->get('hook_permission'), $this)
39 ->addFix('hook_to_YAML', [
40 'hook' => 'permission',
41 'destination' => '~/' . $target->id() . '.permissions.yml',