Commit d89c1f70 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2289917 by Wim Leers, mdrummond, lauriii, Manuel Garcia, emma.maria,...

Issue #2289917 by Wim Leers, mdrummond, lauriii, Manuel Garcia, emma.maria, Scionar, davidhernandez: Convert "messages" page element into blocks
parent 0fd920cb
Loading
Loading
Loading
Loading
+1 −28
Changes for core/includes/theme.inc: 1 added line, 28 removed lines.
Original line number Diff line number Diff line
@@ -500,25 +500,6 @@ function template_preprocess_datetime_wrapper(&$variables) {
  $variables['content'] = $element['#children'];
}

/**
 * Prepares variables for status message templates.
 *
 * Default template: status-messages.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - display: (optional) May have a value of 'status' or 'error' when only
 *     displaying messages of that specific type.
 */
function template_preprocess_status_messages(&$variables) {
  $variables['message_list'] = drupal_get_messages($variables['display']);
  $variables['status_headings'] = array(
    'status' => t('Status message'),
    'error' => t('Error message'),
    'warning' => t('Warning message'),
  );
}

/**
 * Prepares variables for links templates.
 *
@@ -1376,7 +1357,6 @@ function template_preprocess_page(&$variables) {
  $site_config = \Drupal::config('system.site');

  // Move some variables to the top level for themer convenience and template cleanliness.
  $variables['show_messages'] = $variables['page']['#show_messages'];
  $variables['title'] = $variables['page']['#title'];

  foreach (system_region_list(\Drupal::theme()->getActiveTheme()->getName()) as $region_key => $region_name) {
@@ -1414,13 +1394,6 @@ function template_preprocess_page(&$variables) {
  if ($node = \Drupal::routeMatch()->getParameter('node')) {
    $variables['node'] = $node;
  }

  // Prepare render array for messages. drupal_get_messages() is called later,
  // when this variable is rendered in a theme function or template file.
  $variables['messages'] = array(
    '#theme' => 'status_messages',
    '#access' => $variables['show_messages'],
  );
}

/**
@@ -1763,7 +1736,7 @@ function drupal_common_theme() {
      'render element' => 'element',
    ),
    'status_messages' => array(
      'variables' => array('display' => NULL),
      'variables' => ['status_headings' => [], 'message_list' => NULL],
    ),
    'links' => array(
      'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array(), 'set_active_class' => FALSE),
+1 −1
Changes for core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ trait CommandWithAttachedAssetsTrait {
  protected function getRenderedContent() {
    $this->attachedAssets = new AttachedAssets();
    if (is_array($this->content)) {
      $html = \Drupal::service('renderer')->render($this->content);
      $html = \Drupal::service('renderer')->renderRoot($this->content);
      $this->attachedAssets = AttachedAssets::createFromRenderArray($this->content);
      return $html;
    }
+20 −0
Changes for core/lib/Drupal/Core/Block/MessagesBlockPluginInterface.php: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Contains \Drupal\Core\Block\MessagesBlockPluginInterface.
 */

namespace Drupal\Core\Block;

/**
 * The interface for "messages" (#type => status_messages) blocks.
 *
 * @see drupal_set_message()
 * @see drupal_get_message()
 * @see \Drupal\Core\Render\Element\StatusMessages
 * @see \Drupal\block\Plugin\DisplayVariant\BlockPageVariant
 *
 * @ingroup block_api
 */
interface MessagesBlockPluginInterface extends BlockPluginInterface { }
+4 −1
Changes for core/lib/Drupal/Core/Display/Annotation/PageDisplayVariant.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -11,7 +11,10 @@
 * Defines a page display variant annotation object.
 *
 * Page display variants are a specific type of display variant, intended to
 * render the main content of a page.
 * render entire pages. They must render the crucial parts of a page, which are:
 * - the title
 * - the main content
 * - any messages (#type => status_messages)
 *
 * @see \Drupal\Core\Display\VariantInterface
 * @see \Drupal\Core\Display\PageVariantInterface
+1 −0
Changes for core/lib/Drupal/Core/Extension/ThemeHandler.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -465,6 +465,7 @@ public function rebuildThemeData() {
        'secondary_menu' => 'Secondary menu',
        'footer' => 'Footer',
        'highlighted' => 'Highlighted',
        'messages' => 'Messages',
        'help' => 'Help',
        'page_top' => 'Page top',
        'page_bottom' => 'Page bottom',
Loading