You are here

function bootstrap_layouts_theme_registry_alter in Bootstrap Layouts 8.4

Same name and namespace in other branches
  1. 8.5 bootstrap_layouts.module \bootstrap_layouts_theme_registry_alter()

Implements hook_theme_registry_alter().

File

./bootstrap_layouts.module, line 18
Contains bootstrap_layouts.module.

Code

function bootstrap_layouts_theme_registry_alter(&$theme_registry) {

  // Find all Bootstrap Layouts.
  $layouts = Layout::layoutPluginManager()
    ->getDefinitions();
  $layout_theme_hooks = [];
  foreach ($layouts as $info) {
    if ($info['class'] === '\\Drupal\\bootstrap_layouts\\Plugin\\Layout\\BootstrapLayoutsBase') {
      $layout_theme_hooks[] = $info['theme'];
    }
  }

  // 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';
    }
  }
}