/**
  * {@inheritdoc}
  */
 public function convert(TargetInterface $target)
 {
     $info_file = $target->getPath('.info');
     $info = self::parseInfo($info_file);
     $info['core'] = '8.x';
     $info['type'] = 'module';
     if (isset($info['dependencies'])) {
         // array_values() is called in order to reindex the array. Issue #2340207
         $info['dependencies'] = array_values(array_diff($info['dependencies'], ['ctools', 'list']));
     }
     unset($info['files'], $info['configure']);
     $this->writeInfo($target, 'info', $info);
 }
 /**
  * {@inheritdoc}
  */
 public function analyze(TargetInterface $target)
 {
     $issues = [];
     $info_file = $target->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;
 }
 /**
  * Writes out arbitrary data in YAML format.
  *
  * @param TargetInterface $target
  *  The target module.
  * @param string $group
  *  The name of the YAML file. It will be prefixed with the module's machine
  *  name and suffixed with .yml. For example, a group value of 'routing'
  *  will write MODULE.routing.yml.
  * @param array $data
  *  The data to write.
  *
  * @todo This should be writeYAML, not writeInfo.
  */
 protected function writeInfo(TargetInterface $target, $group, array $data)
 {
     $destination = $target->getPath('.' . $group . '.yml');
     file_put_contents($destination, Yaml::encode($data));
 }