function at_tools_library_info_alter in AT Tools 8.3
Same name and namespace in other branches
- 8.2 at_tools.module \at_tools_library_info_alter()
Implements hook_library_info_alter().
Parameters
array $libraries: An associative array of libraries registered by $extension. Keyed by internal library name and passed by reference.
string $extension: Can either be 'core' or the machine name of the extension that registered the libraries.
File
- ./
at_tools.module, line 44 - Contains at_tools.module
Code
function at_tools_library_info_alter(&$libraries, $extension) {
$themes = \Drupal::service('theme_handler')
->listInfo();
$active_theme = \Drupal::theme()
->getActiveTheme()
->getName();
$config_active_theme = \Drupal::config($active_theme . '.settings')
->get('settings');
if (isset($config_active_theme['enable_devel']) && $config_active_theme['enable_devel'] === 1) {
if (isset($config_active_theme['enable_live_reload']) && $config_active_theme['enable_live_reload'] === 1) {
$live_reload_port = isset($config_active_theme['live_reload_port']) ? Html::escape($config_active_theme['live_reload_port']) : '35729';
$live_reload_path = '//localhost:' . $live_reload_port . '/livereload.js';
$libraries['at.livereload']['js'] = [
$live_reload_path => [],
];
}
}
// Replace the layout form CSS with the right stylesheet (in Layout Settings).
if (\Drupal::service('router.admin_context')
->isAdminRoute(\Drupal::routeMatch()
->getRouteObject())) {
if (isset($config_active_theme['layouts_enable']) && $config_active_theme['layouts_enable'] === 1) {
foreach ($themes as $theme_key => $theme_info) {
if (isset($theme_info->info['layout']) && $theme_key == $extension) {
$layout_data = new LayoutCompatible($theme_key);
$layout_compatible_data = $layout_data
->getCompatibleLayout();
$css_config = $layout_compatible_data['css_config'];
$layout_form_css = drupal_get_path('theme', $css_config['layout_provider']) . '/layout/' . $css_config['layout'] . '/' . $css_config['css_form_styles_path'];
if (file_exists($layout_form_css)) {
$libraries['layout_settings']['css']['theme'] = [
'/' . $layout_form_css => [],
];
}
}
}
}
}
}