3 namespace Drupal\system\Plugin\Block;
5 use Drupal\Core\Block\BlockBase;
6 use Drupal\Core\Block\MessagesBlockPluginInterface;
7 use Drupal\Core\Cache\Cache;
10 * Provides a block to display the messages.
12 * @see drupal_set_message()
15 * id = "system_messages_block",
16 * admin_label = @Translation("Messages")
19 class SystemMessagesBlock extends BlockBase implements MessagesBlockPluginInterface {
24 public function defaultConfiguration() {
26 'label_display' => FALSE,
33 public function build() {
34 return ['#type' => 'status_messages'];
40 public function getCacheMaxAge() {
41 // The messages are session-specific and hence aren't cacheable, but the
42 // block itself *is* cacheable because it uses a #lazy_builder callback and
43 // hence the block has a globally cacheable render array.
44 return Cache::PERMANENT;