Mercurial > hg > isophonics-drupal-site
annotate core/modules/system/src/Plugin/Block/SystemMessagesBlock.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children | af1871eacc83 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\system\Plugin\Block; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Block\BlockBase; |
Chris@0 | 6 use Drupal\Core\Block\MessagesBlockPluginInterface; |
Chris@0 | 7 use Drupal\Core\Cache\Cache; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Provides a block to display the messages. |
Chris@0 | 11 * |
Chris@17 | 12 * @see @see \Drupal\Core\Messenger\MessengerInterface |
Chris@0 | 13 * |
Chris@0 | 14 * @Block( |
Chris@0 | 15 * id = "system_messages_block", |
Chris@0 | 16 * admin_label = @Translation("Messages") |
Chris@0 | 17 * ) |
Chris@0 | 18 */ |
Chris@0 | 19 class SystemMessagesBlock extends BlockBase implements MessagesBlockPluginInterface { |
Chris@0 | 20 |
Chris@0 | 21 /** |
Chris@0 | 22 * {@inheritdoc} |
Chris@0 | 23 */ |
Chris@0 | 24 public function defaultConfiguration() { |
Chris@0 | 25 return [ |
Chris@0 | 26 'label_display' => FALSE, |
Chris@0 | 27 ]; |
Chris@0 | 28 } |
Chris@0 | 29 |
Chris@0 | 30 /** |
Chris@0 | 31 * {@inheritdoc} |
Chris@0 | 32 */ |
Chris@0 | 33 public function build() { |
Chris@0 | 34 return ['#type' => 'status_messages']; |
Chris@0 | 35 } |
Chris@0 | 36 |
Chris@0 | 37 /** |
Chris@0 | 38 * {@inheritdoc} |
Chris@0 | 39 */ |
Chris@0 | 40 public function getCacheMaxAge() { |
Chris@0 | 41 // The messages are session-specific and hence aren't cacheable, but the |
Chris@0 | 42 // block itself *is* cacheable because it uses a #lazy_builder callback and |
Chris@0 | 43 // hence the block has a globally cacheable render array. |
Chris@0 | 44 return Cache::PERMANENT; |
Chris@0 | 45 } |
Chris@0 | 46 |
Chris@0 | 47 } |