SectionStorageBase.php in Drupal 8
File
core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php
View source
<?php
namespace Drupal\layout_builder\Plugin\SectionStorage;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\ContextAwarePluginBase;
use Drupal\layout_builder\Routing\LayoutBuilderRoutesTrait;
use Drupal\layout_builder\Section;
use Drupal\layout_builder\SectionListInterface;
use Drupal\layout_builder\SectionStorageInterface;
use Drupal\layout_builder\TempStoreIdentifierInterface;
abstract class SectionStorageBase extends ContextAwarePluginBase implements SectionStorageInterface, TempStoreIdentifierInterface {
use LayoutBuilderRoutesTrait;
public function setSectionList(SectionListInterface $section_list) {
@trigger_error('\\Drupal\\layout_builder\\SectionStorageInterface::setSectionList() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. This method should no longer be used. The section list should be derived from context. See https://www.drupal.org/node/3016262.', E_USER_DEPRECATED);
throw new \Exception('\\Drupal\\layout_builder\\SectionStorageInterface::setSectionList() must no longer be called. The section list should be derived from context. See https://www.drupal.org/node/3016262.');
}
protected abstract function getSectionList();
public function getStorageType() {
return $this
->getPluginId();
}
public function count() {
return $this
->getSectionList()
->count();
}
public function getSections() {
return $this
->getSectionList()
->getSections();
}
public function getSection($delta) {
return $this
->getSectionList()
->getSection($delta);
}
public function appendSection(Section $section) {
$this
->getSectionList()
->appendSection($section);
return $this;
}
public function insertSection($delta, Section $section) {
$this
->getSectionList()
->insertSection($delta, $section);
return $this;
}
public function removeSection($delta) {
$this
->getSectionList()
->removeSection($delta);
return $this;
}
public function removeAllSections($set_blank = FALSE) {
$this
->getSectionList()
->removeAllSections($set_blank);
return $this;
}
public function getContextsDuringPreview() {
$contexts = $this
->getContexts();
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;
}
public function getTempstoreKey() {
return $this
->getStorageId();
}
}