X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flayout_builder%2Fsrc%2FPlugin%2FSectionStorage%2FSectionStorageBase.php;fp=web%2Fcore%2Fmodules%2Flayout_builder%2Fsrc%2FPlugin%2FSectionStorage%2FSectionStorageBase.php;h=c419060c45b8ac068a63ae13f5cc118a42a2302d;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php b/web/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php new file mode 100644 index 000000000..c419060c4 --- /dev/null +++ b/web/core/modules/layout_builder/src/Plugin/SectionStorage/SectionStorageBase.php @@ -0,0 +1,106 @@ +sectionList = $section_list; + return $this; + } + + /** + * Gets the section list. + * + * @return \Drupal\layout_builder\SectionListInterface + * The section list. + * + * @throws \RuntimeException + * Thrown if ::setSectionList() is not called first. + */ + protected function getSectionList() { + if (!$this->sectionList) { + throw new \RuntimeException(sprintf('%s::setSectionList() must be called first', static::class)); + } + return $this->sectionList; + } + + /** + * {@inheritdoc} + */ + public function getStorageType() { + return $this->getPluginId(); + } + + /** + * {@inheritdoc} + */ + 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; + } + +}