class TestCacheBlock
Same name in other branches
- 9 core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php \Drupal\block_test\Plugin\Block\TestCacheBlock
- 10 core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php \Drupal\block_test\Plugin\Block\TestCacheBlock
- 11.x core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php \Drupal\block_test\Plugin\Block\TestCacheBlock
Provides a block to test caching.
Plugin annotation
@Block(
id = "test_cache",
admin_label = @Translation("Test block caching")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Component\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\ContextAwarePluginInterface
- class \Drupal\Core\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\ContextAwarePluginBase implements \Drupal\Core\Plugin\ContextAwarePluginInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Core\TypedData\TypedDataTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Block\BlockBase extends \Drupal\Core\Plugin\ContextAwarePluginBase implements \Drupal\Core\Block\BlockPluginInterface, \Drupal\Core\Plugin\PluginWithFormsInterface, \Drupal\Core\Render\PreviewFallbackInterface uses \Drupal\Core\Block\BlockPluginTrait, \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait
- class \Drupal\block_test\Plugin\Block\TestCacheBlock extends \Drupal\Core\Block\BlockBase
- class \Drupal\Core\Block\BlockBase extends \Drupal\Core\Plugin\ContextAwarePluginBase implements \Drupal\Core\Block\BlockPluginInterface, \Drupal\Core\Plugin\PluginWithFormsInterface, \Drupal\Core\Render\PreviewFallbackInterface uses \Drupal\Core\Block\BlockPluginTrait, \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait
- class \Drupal\Core\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\ContextAwarePluginBase implements \Drupal\Core\Plugin\ContextAwarePluginInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Core\TypedData\TypedDataTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Component\Plugin\ContextAwarePluginBase extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\ContextAwarePluginInterface
Expanded class hierarchy of TestCacheBlock
File
-
core/
modules/ block/ tests/ modules/ block_test/ src/ Plugin/ Block/ TestCacheBlock.php, line 15
Namespace
Drupal\block_test\Plugin\BlockView source
class TestCacheBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$content = \Drupal::state()->get('block_test.content');
$build = [];
if (!empty($content)) {
$build['#markup'] = $content;
}
return $build;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return \Drupal::state()->get('block_test.cache_contexts', []);
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return \Drupal::state()->get('block_test.cache_max_age', parent::getCacheMaxAge());
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
TestCacheBlock::build | public | function | |
TestCacheBlock::getCacheContexts | public | function | |
TestCacheBlock::getCacheMaxAge | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.