Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / HookLibrary.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter;
4
5 use Drupal\drupalmoduleupgrader\ConverterBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
7
8 /**
9  * @Converter(
10  *  id = "hook_library",
11  *  description = @Translation("Converts Drupal 7's hook_library() to YAML."),
12  *  hook = "hook_library"
13  * )
14  */
15 class HookLibrary extends ConverterBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function convert(TargetInterface $target) {
21     try {
22       $libraries = $this->executeHook($target, $this->pluginDefinition['hook']);
23     }
24     catch (\LogicException $e) {
25       return;
26     }
27
28     foreach ($libraries as $id => &$lib) {
29       if (isset($lib['website'])) {
30         $lib['remote'] = $lib['website'];
31         unset($lib['website']);
32       }
33
34       if (isset($lib['dependencies'])) {
35         $lib['dependencies'] = array_map(function(array $dependency) {
36           if ($dependency[0] == 'system') {
37             $dependency[0] == 'core';
38           }
39           return implode('/', $dependency);
40         }, $lib['dependencies']);
41       }
42     }
43
44     $this->writeInfo($target, 'libraries', $libraries);
45   }
46
47 }