Mercurial > hg > isophonics-drupal-site
annotate core/modules/system/src/Plugin/Block/SystemMessagesBlock.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | af1871eacc83 |
children |
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@18 | 34 return [ |
Chris@18 | 35 '#type' => 'status_messages', |
Chris@18 | 36 '#include_fallback' => TRUE, |
Chris@18 | 37 ]; |
Chris@0 | 38 } |
Chris@0 | 39 |
Chris@0 | 40 /** |
Chris@0 | 41 * {@inheritdoc} |
Chris@0 | 42 */ |
Chris@0 | 43 public function getCacheMaxAge() { |
Chris@0 | 44 // The messages are session-specific and hence aren't cacheable, but the |
Chris@0 | 45 // block itself *is* cacheable because it uses a #lazy_builder callback and |
Chris@0 | 46 // hence the block has a globally cacheable render array. |
Chris@0 | 47 return Cache::PERMANENT; |
Chris@0 | 48 } |
Chris@0 | 49 |
Chris@0 | 50 } |