X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FAnalyzer%2FInfoFile.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FAnalyzer%2FInfoFile.php;h=1e21e950391da3eef5d63b9204aa2e224152fc5e;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Analyzer/InfoFile.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Analyzer/InfoFile.php new file mode 100644 index 000000000..1e21e9503 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Analyzer/InfoFile.php @@ -0,0 +1,70 @@ +getPath('.info'); + if (! file_exists($info_file)) { + return $issues; + } + + $info = \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\InfoToYAML::parseInfo($info_file); + if (empty($info)) { + throw new \RuntimeException('Cannot parse info file ' . $info_file); + } + + $doc = $this->pluginDefinition['documentation'][0]; + if ($info['core'] != '8.x') { + $issues['core'] = new Issue($target, $this->t("Module info files' `core` key must have a value of `8.x`.")); + $issues['core']->addDocumentation($doc['url'], $doc['title']); + } + if (empty($info['type'])) { + $issues['type'] = new Issue($target, $this->t('Info files must contain a `type` key.')); + $issues['type']->addDocumentation($doc['url'] . '#type', $doc['title']); + } + if (isset($info['dependencies'])) { + $issues['dependencies'] = new Issue($target, $this->t('Many common dependencies have moved into core.')); + $issues['dependencies']->addDocumentation($doc['url'], $doc['title']); + } + if (isset($info['files'])) { + $issues['files'] = new Issue($target, $this->t('Modules no longer declare classes in their info file.')); + $issues['files']->addDocumentation($doc['url'] . '#files', $doc['title']); + } + if (isset($info['configure'])) { + $issues['configure'] = new Issue($target, $this->t("Module info files' `configure` key must be a route name, not a path.")); + $issues['configure']->addDocumentation($doc['url'] . '#configure', $doc['title']); + } + + /** @var \Drupal\drupalmoduleupgrader\IssueInterface $issue */ + foreach ($issues as $key => $issue) { + $issue->setTag('error_level', 'error'); + $issue->setTag('category', ['info']); + $issue->addAffectedFile($info_file, $this); + } + + return $issues; + } + +}