Messages.php

Same filename in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/area/Messages.php
  2. 10 core/modules/views/src/Plugin/views/area/Messages.php
  3. 11.x core/modules/views/src/Plugin/views/area/Messages.php

Namespace

Drupal\views\Plugin\views\area

File

core/modules/views/src/Plugin/views/area/Messages.php

View source
<?php

namespace Drupal\views\Plugin\views\area;


/**
 * Provides an area for messages.
 *
 * @ingroup views_area_handlers
 *
 * @ViewsArea("messages")
 */
class Messages extends AreaPluginBase {
    
    /**
     * {@inheritdoc}
     */
    protected function defineOptions() {
        $options = parent::defineOptions();
        // Set the default to TRUE so it shows on empty pages by default.
        $options['empty']['default'] = TRUE;
        return $options;
    }
    
    /**
     * {@inheritdoc}
     */
    public function render($empty = FALSE) {
        if (!$empty || !empty($this->options['empty'])) {
            return [
                '#type' => 'status_messages',
            ];
        }
        return [];
    }

}

Classes

Title Deprecated Summary
Messages Provides an area for messages.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.