You are here

function entity_browser_preprocess_page__entity_browser__iframe in Entity Browser 8.2

Same name and namespace in other branches
  1. 8 entity_browser.module \entity_browser_preprocess_page__entity_browser__iframe()

Implements hook_preprocess_page__entity_browser__iframe().

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

1 call to entity_browser_preprocess_page__entity_browser__iframe()
entity_browser_preprocess_page__entity_browser__modal in ./entity_browser.module
Implements hook_preprocess_page__entity_browser__modal().

File

./entity_browser.module, line 96
Allows to flexibly create, browse and select entities.

Code

function entity_browser_preprocess_page__entity_browser__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()];
  }
}