class TestStateBasedSectionStorage in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/TestStateBasedSectionStorage.php \Drupal\layout_builder_test\Plugin\SectionStorage\TestStateBasedSectionStorage
- 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/TestStateBasedSectionStorage.php \Drupal\layout_builder_test\Plugin\SectionStorage\TestStateBasedSectionStorage
Provides a test section storage that is controlled by state.
Plugin annotation
@SectionStorage(
id = "layout_builder_test_state",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase implements CacheableDependencyInterface, SectionStorageInterface, TempStoreIdentifierInterface uses ContextAwarePluginTrait, LayoutBuilderRoutesTrait
- class \Drupal\layout_builder_test\Plugin\SectionStorage\TestStateBasedSectionStorage
- class \Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase implements CacheableDependencyInterface, SectionStorageInterface, TempStoreIdentifierInterface uses ContextAwarePluginTrait, LayoutBuilderRoutesTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TestStateBasedSectionStorage
File
- core/
modules/ layout_builder/ tests/ modules/ layout_builder_test/ src/ Plugin/ SectionStorage/ TestStateBasedSectionStorage.php, line 19
Namespace
Drupal\layout_builder_test\Plugin\SectionStorageView source
class TestStateBasedSectionStorage extends SectionStorageBase {
/**
* {@inheritdoc}
*/
public function getSections() {
// Return a custom section.
$section = new Section('layout_onecol');
$section
->appendComponent(new SectionComponent('fake-uuid', 'content', [
'id' => 'system_powered_by_block',
'label' => 'Test block title',
'label_display' => 'visible',
]));
return [
$section,
];
}
/**
* {@inheritdoc}
*/
public function isApplicable(RefinableCacheableDependencyInterface $cacheability) {
$cacheability
->mergeCacheMaxAge(0);
return \Drupal::state()
->get('layout_builder_test_state', FALSE);
}
/**
* {@inheritdoc}
*/
public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
protected function getSectionList() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function getStorageId() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function getSectionListFromId($id) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function buildRoutes(RouteCollection $collection) {
}
/**
* {@inheritdoc}
*/
public function getRedirectUrl() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function getLayoutBuilderUrl($rel = 'view') {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function extractIdFromRoute($value, $definition, $name, array $defaults) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function deriveContextsFromRoute($value, $definition, $name, array $defaults) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function label() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function save() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
}