3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer;
5 use Drupal\drupalmoduleupgrader\AnalyzerBase;
6 use Drupal\drupalmoduleupgrader\Issue;
7 use Drupal\drupalmoduleupgrader\TargetInterface;
12 * description = @Translation("Analyzes Drupal 7 info files."),
15 * "url" = "https://www.drupal.org/node/1935708",
16 * "title" = @Translation("`.info` files are now `.info.yml` files")
21 class InfoFile extends AnalyzerBase {
26 public function analyze(TargetInterface $target) {
28 $info_file = $target->getPath('.info');
29 if (! file_exists($info_file)) {
33 $info = \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\InfoToYAML::parseInfo($info_file);
35 throw new \RuntimeException('Cannot parse info file ' . $info_file);
38 $doc = $this->pluginDefinition['documentation'][0];
39 if ($info['core'] != '8.x') {
40 $issues['core'] = new Issue($target, $this->t("Module info files' `core` key must have a value of `8.x`."));
41 $issues['core']->addDocumentation($doc['url'], $doc['title']);
43 if (empty($info['type'])) {
44 $issues['type'] = new Issue($target, $this->t('Info files must contain a `type` key.'));
45 $issues['type']->addDocumentation($doc['url'] . '#type', $doc['title']);
47 if (isset($info['dependencies'])) {
48 $issues['dependencies'] = new Issue($target, $this->t('Many common dependencies have moved into core.'));
49 $issues['dependencies']->addDocumentation($doc['url'], $doc['title']);
51 if (isset($info['files'])) {
52 $issues['files'] = new Issue($target, $this->t('Modules no longer declare classes in their info file.'));
53 $issues['files']->addDocumentation($doc['url'] . '#files', $doc['title']);
55 if (isset($info['configure'])) {
56 $issues['configure'] = new Issue($target, $this->t("Module info files' `configure` key must be a route name, not a path."));
57 $issues['configure']->addDocumentation($doc['url'] . '#configure', $doc['title']);
60 /** @var \Drupal\drupalmoduleupgrader\IssueInterface $issue */
61 foreach ($issues as $key => $issue) {
62 $issue->setTag('error_level', 'error');
63 $issue->setTag('category', ['info']);
64 $issue->addAffectedFile($info_file, $this);