You are here

function bootstrap4_modal_preprocess_page__entity_browser__bootstrap4_iframe in Bootstrap 4 Modal 8

Same name and namespace in other branches
  1. 2.x bootstrap4_modal.module \bootstrap4_modal_preprocess_page__entity_browser__bootstrap4_iframe()

Implements hook_preprocess_page__entity_browser__bootstrap4_iframe().

Tries to figure out where messages block lives and display it separately.

1 call to bootstrap4_modal_preprocess_page__entity_browser__bootstrap4_iframe()
bootstrap4_modal_preprocess_page__entity_browser__bootstrap4_modal in ./bootstrap4_modal.module
Implements hook_preprocess_page__entity_browser__bootstrap4_modal().

File

./bootstrap4_modal.module, line 66
Contains bootstrap4_modal.module.

Code

function bootstrap4_modal_preprocess_page__entity_browser__bootstrap4_iframe(&$variables) {
  if (!\Drupal::moduleHandler()
    ->moduleExists('block')) {
    return;
  }
  $variables['messages'] = '';
  $blocks = \Drupal::entityTypeManager()
    ->getStorage('block')
    ->loadByProperties([
    'theme' => \Drupal::theme()
      ->getActiveTheme()
      ->getName(),
    'plugin' => 'system_messages_block',
  ]);
  if (($messages = current($blocks)) && !empty($variables['page'][$messages
    ->getRegion()][$messages
    ->id()])) {
    $variables['messages'] = $variables['page'][$messages
      ->getRegion()][$messages
      ->id()];
  }
}