You are here

function context_preprocess_page in Context 8

Same name and namespace in other branches
  1. 6.3 context.core.inc \context_preprocess_page()
  2. 6 context.core.inc \context_preprocess_page()
  3. 6.2 context.core.inc \context_preprocess_page()
  4. 7.3 context.core.inc \context_preprocess_page()

Implements hook_preprocess_page().

File

./context.module, line 58

Code

function context_preprocess_page(&$variables) {

  // Active theme for route.
  $current_theme = \Drupal::service('theme.negotiator')
    ->determineActiveTheme(Drupal::routeMatch());

  // Context manager.
  $context_manager = \Drupal::service('context.manager');

  // Disable regions based on regions reaction.
  foreach ($context_manager
    ->getActiveReactions('regions') as $region_reaction) {
    $configuration = $region_reaction
      ->getConfiguration();
    if (isset($configuration['regions'][$current_theme])) {
      foreach ($configuration['regions'][$current_theme] as $region) {
        unset($variables['page'][$region]);
      }
    }
  }
}