Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/src/Plugin/Block/SystemMessagesBlock.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\system\Plugin\Block; | |
4 | |
5 use Drupal\Core\Block\BlockBase; | |
6 use Drupal\Core\Block\MessagesBlockPluginInterface; | |
7 use Drupal\Core\Cache\Cache; | |
8 | |
9 /** | |
10 * Provides a block to display the messages. | |
11 * | |
12 * @see drupal_set_message() | |
13 * | |
14 * @Block( | |
15 * id = "system_messages_block", | |
16 * admin_label = @Translation("Messages") | |
17 * ) | |
18 */ | |
19 class SystemMessagesBlock extends BlockBase implements MessagesBlockPluginInterface { | |
20 | |
21 /** | |
22 * {@inheritdoc} | |
23 */ | |
24 public function defaultConfiguration() { | |
25 return [ | |
26 'label_display' => FALSE, | |
27 ]; | |
28 } | |
29 | |
30 /** | |
31 * {@inheritdoc} | |
32 */ | |
33 public function build() { | |
34 return ['#type' => 'status_messages']; | |
35 } | |
36 | |
37 /** | |
38 * {@inheritdoc} | |
39 */ | |
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; | |
45 } | |
46 | |
47 } |