public function HookLibrary::convert in Drupal 7 to 8/9 Module Upgrader 8
Performs required conversions.
Parameters
TargetInterface $target: The target module to convert.
Overrides ConverterInterface::convert
File
- src/
Plugin/ DMU/ Converter/ HookLibrary.php, line 20
Class
- HookLibrary
- Plugin annotation @Converter( id = "hook_library", description = @Translation("Converts Drupal 7's hook_library() to YAML."), hook = "hook_library" )
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\ConverterCode
public function convert(TargetInterface $target) {
try {
$libraries = $this
->executeHook($target, $this->pluginDefinition['hook']);
} catch (\LogicException $e) {
return;
}
foreach ($libraries as $id => &$lib) {
if (isset($lib['website'])) {
$lib['remote'] = $lib['website'];
unset($lib['website']);
}
if (isset($lib['dependencies'])) {
$lib['dependencies'] = array_map(function (array $dependency) {
if ($dependency[0] == 'system') {
$dependency[0] == 'core';
}
return implode('/', $dependency);
}, $lib['dependencies']);
}
}
$this
->writeInfo($target, 'libraries', $libraries);
}