function sdc_library_info_build
Same name in other branches
- 11.x core/modules/sdc/sdc.module \sdc_library_info_build()
Implements hook_library_info_build().
File
-
core/
modules/ sdc/ sdc.module, line 33
Code
function sdc_library_info_build() {
$deprecation_message = 'The %library_id% asset library is deprecated in Drupal 10.3.0 and will be removed in Drupal 11.0.0. Use the core/components.[component-id] library instead. See https://www.drupal.org/node/3410260';
// 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();
// Generate backwards compatible deprecated libraries that depend on the new
// library name scheme.
$libraries = array_reduce($components, static function (array $libraries, Component $component) use ($deprecation_message) {
// The library name is something like core/components.my-theme--my-comp.
$library_name = $component->getLibraryName();
// The library ID is something like my-theme--my-comp.
$library_id = str_replace('core/components.', '', $library_name);
// Adding these libraries will result in the old 'sdc/my-theme--my-comp'.
return array_merge($libraries, [
$library_id => [
'dependencies' => [
$library_name,
],
'deprecated' => $deprecation_message,
],
]);
}, []);
// Alias the library sdc/all to core/components.all.
$libraries['all'] = [
'dependencies' => [
'core/components.all',
],
'deprecated' => 'The %library_id% asset library is deprecated in Drupal 10.3.0 and will be removed in Drupal 11.0.0. Use the core/components.all library instead. See https://www.drupal.org/node/3410260',
];
return $libraries;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.