function sdc_library_info_build
Same name in other branches
- 10 core/modules/sdc/sdc.module \sdc_library_info_build()
Implements hook_library_info_build().
File
-
core/
modules/ sdc/ sdc.module, line 52
Code
function sdc_library_info_build() {
// Iterate over all the components to get the CSS and JS files.
$plugin_manager = \Drupal::service('plugin.manager.sdc');
assert($plugin_manager instanceof ComponentPluginManager);
$components = $plugin_manager->getAllComponents();
$libraries = array_reduce($components, static function (array $libraries, Component $component) {
$library = $component->library;
if (empty($library)) {
return $libraries;
}
$library_name = $component->getLibraryName();
[
,
$library_id,
] = explode('/', $library_name);
return array_merge($libraries, [
$library_id => $library,
]);
}, []);
$libraries['all'] = [
'dependencies' => array_map(static fn(Component $component) => $component->getLibraryName(), $components),
];
return $libraries;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.