Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Analyzer / HookPermission.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer;
4
5 use Drupal\drupalmoduleupgrader\AnalyzerBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
7
8 /**
9  * @Analyzer(
10  *  id = "hook_permission",
11  *  description = @Translation("Analyzes implementations of hook_permission()."),
12  *  documentation = {
13  *    {
14  *      "url" = "https://www.drupal.org/node/2311427",
15  *      "title" = @Translation("Defining permissions in `MODULE.permissions.yml`")
16  *    }
17  *  },
18  *  tags = {
19  *    "category" = { "system", "user" },
20  *    "error_level" = "warning"
21  *  },
22  *  hook = "hook_permission",
23  *  message = @Translation("Static permissions are now defined in `MODULE.permissions.yml`.")
24  * )
25  */
26 class HookPermission extends AnalyzerBase {
27
28   /**
29    * {@inheritdoc}
30    */
31   public function analyze(TargetInterface $target) {
32     $issues = [];
33     $indexer = $target->getIndexer('function');
34
35     if ($indexer->hasExecutable('hook_permission')) {
36       $issues[] = $this
37         ->buildIssue($target)
38         ->addViolation($indexer->get('hook_permission'), $this)
39         ->addFix('hook_to_YAML', [
40           'hook' => 'permission',
41           'destination' => '~/' . $target->id() . '.permissions.yml',
42         ]);
43     }
44
45     return $issues;
46   }
47
48 }