3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter;
5 use Drupal\drupalmoduleupgrader\ConverterBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
10 * id = "hook_library",
11 * description = @Translation("Converts Drupal 7's hook_library() to YAML."),
12 * hook = "hook_library"
15 class HookLibrary extends ConverterBase {
20 public function convert(TargetInterface $target) {
22 $libraries = $this->executeHook($target, $this->pluginDefinition['hook']);
24 catch (\LogicException $e) {
28 foreach ($libraries as $id => &$lib) {
29 if (isset($lib['website'])) {
30 $lib['remote'] = $lib['website'];
31 unset($lib['website']);
34 if (isset($lib['dependencies'])) {
35 $lib['dependencies'] = array_map(function(array $dependency) {
36 if ($dependency[0] == 'system') {
37 $dependency[0] == 'core';
39 return implode('/', $dependency);
40 }, $lib['dependencies']);
44 $this->writeInfo($target, 'libraries', $libraries);