function bootstrap_layouts_theme_registry_alter in Bootstrap Layouts 8.5
Same name and namespace in other branches
- 8.4 bootstrap_layouts.module \bootstrap_layouts_theme_registry_alter()
Implements hook_theme_registry_alter().
File
- ./
bootstrap_layouts.module, line 17 - Contains bootstrap_layouts.module.
Code
function bootstrap_layouts_theme_registry_alter(&$theme_registry) {
// Immediately return if the layout manager cannot be loaded.
// This can happen during the update process.
if (!\Drupal::hasService('plugin.manager.core.layout')) {
return;
}
// Find all Bootstrap Layouts.
$layouts = \Drupal::service('plugin.manager.core.layout')
->getDefinitions();
$layout_theme_hooks = [];
/** @var \Drupal\Core\Layout\LayoutDefinition $info */
foreach ($layouts as $info) {
if ($info
->getClass() === 'Drupal\\bootstrap_layouts\\Plugin\\Layout\\BootstrapLayoutsBase') {
$layout_theme_hooks[] = $info
->getThemeHook();
}
}
// Add a special internal preprocess function.
foreach ($theme_registry as $theme_hook => $info) {
if (in_array($theme_hook, $layout_theme_hooks) || !empty($info['base hook']) && in_array($info['base hook'], $layout_theme_hooks)) {
$theme_registry[$theme_hook]['preprocess functions'][] = '_bootstrap_layouts_preprocess_layout';
}
}
}