diff --git a/entity_browser.module b/entity_browser.module index c5c0637..aa71fda 100644 --- a/entity_browser.module +++ b/entity_browser.module @@ -55,3 +55,27 @@ function entity_browser_form_alter(&$form, FormStateInterface &$form_state) { ]; } } + +/** + * Implements hook_preprocess_page__entity_browser__iframe(). + * + * Tries to figure out where messages block lives and display it separately. + */ +function entity_browser_preprocess_page__entity_browser__iframe(&$variables) { + $blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties([ + 'theme' => \Drupal::theme()->getActiveTheme()->getName(), + 'plugin' => 'system_messages_block', + ]); + if ($messages = current($blocks)) { + $variables['messages'] = $variables['page'][$messages->getRegion()][$messages->id()]; + } +} + +/** + * Implements hook_preprocess_page__entity_browser__modal(). + * + * Tries to figure out where messages block lives and display it separately. + */ +function entity_browser_preprocess_page__entity_browser__modal(&$variables) { + entity_browser_preprocess_page__entity_browser__iframe($variables); +} diff --git a/templates/page--entity-browser--iframe.html.twig b/templates/page--entity-browser--iframe.html.twig index 1b62be2..ec7e454 100644 --- a/templates/page--entity-browser--iframe.html.twig +++ b/templates/page--entity-browser--iframe.html.twig @@ -9,6 +9,15 @@ #}