function TestCacheBlock::build

Same name and namespace in other branches
  1. 8.9.x core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php \Drupal\block_test\Plugin\Block\TestCacheBlock::build()
  2. 10 core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php \Drupal\block_test\Plugin\Block\TestCacheBlock::build()
  3. 11.x core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php \Drupal\block_test\Plugin\Block\TestCacheBlock::build()

Overrides BlockPluginInterface::build

File

core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php, line 20

Class

TestCacheBlock
Provides a block to test caching.

Namespace

Drupal\block_test\Plugin\Block

Code

public function build() {
    $content = \Drupal::state()->get('block_test.content');
    $build = [];
    if (!empty($content)) {
        $build['#markup'] = $content;
    }
    return $build;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.