Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / block / tests / modules / block_test / src / Plugin / Block / TestCacheBlock.php
1 <?php
2
3 namespace Drupal\block_test\Plugin\Block;
4
5 use Drupal\Core\Block\BlockBase;
6
7 /**
8  * Provides a block to test caching.
9  *
10  * @Block(
11  *   id = "test_cache",
12  *   admin_label = @Translation("Test block caching")
13  * )
14  */
15 class TestCacheBlock extends BlockBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function build() {
21     $content = \Drupal::state()->get('block_test.content');
22
23     $build = [];
24     if (!empty($content)) {
25       $build['#markup'] = $content;
26     }
27     return $build;
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public function getCacheContexts() {
34     return \Drupal::state()->get('block_test.cache_contexts', []);
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function getCacheMaxAge() {
41     return \Drupal::state()->get('block_test.cache_max_age', parent::getCacheMaxAge());
42   }
43
44 }