abstract class SectionStorageBase in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php \Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase
- 9 core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php \Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase
Provides a base class for Section Storage types.
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\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SectionStorageBase
1 file declares its use of SectionStorageBase
- TestStateBasedSectionStorage.php in core/
modules/ layout_builder/ tests/ modules/ layout_builder_test/ src/ Plugin/ SectionStorage/ TestStateBasedSectionStorage.php
File
- core/
modules/ layout_builder/ src/ Plugin/ SectionStorage/ SectionStorageBase.php, line 18
Namespace
Drupal\layout_builder\Plugin\SectionStorageView source
abstract class SectionStorageBase extends PluginBase implements SectionStorageInterface, TempStoreIdentifierInterface, CacheableDependencyInterface {
use ContextAwarePluginTrait;
use LayoutBuilderRoutesTrait;
/**
* Gets the section list.
*
* @return \Drupal\layout_builder\SectionListInterface
* The section list.
*/
protected abstract function getSectionList();
/**
* {@inheritdoc}
*/
public function getStorageType() {
return $this
->getPluginId();
}
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function count() {
return $this
->getSectionList()
->count();
}
/**
* {@inheritdoc}
*/
public function getSections() {
return $this
->getSectionList()
->getSections();
}
/**
* {@inheritdoc}
*/
public function getSection($delta) {
return $this
->getSectionList()
->getSection($delta);
}
/**
* {@inheritdoc}
*/
public function appendSection(Section $section) {
$this
->getSectionList()
->appendSection($section);
return $this;
}
/**
* {@inheritdoc}
*/
public function insertSection($delta, Section $section) {
$this
->getSectionList()
->insertSection($delta, $section);
return $this;
}
/**
* {@inheritdoc}
*/
public function removeSection($delta) {
$this
->getSectionList()
->removeSection($delta);
return $this;
}
/**
* {@inheritdoc}
*/
public function removeAllSections($set_blank = FALSE) {
$this
->getSectionList()
->removeAllSections($set_blank);
return $this;
}
/**
* {@inheritdoc}
*/
public function getContextsDuringPreview() {
$contexts = $this
->getContexts();
// view_mode is a required context, but SectionStorage plugins are not
// required to return it (for example, the layout_library plugin provided
// in the Layout Library module. In these instances, explicitly create a
// view_mode context with the value "default".
if (!isset($contexts['view_mode']) || $contexts['view_mode']
->validate()
->count() || !$contexts['view_mode']
->getContextValue()) {
$contexts['view_mode'] = new Context(new ContextDefinition('string'), 'default');
}
return $contexts;
}
/**
* {@inheritdoc}
*/
public function getTempstoreKey() {
return $this
->getStorageId();
}
}