class TestStateBasedSectionStorage

Same name in other branches
  1. 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/TestStateBasedSectionStorage.php \Drupal\layout_builder_test\Plugin\SectionStorage\TestStateBasedSectionStorage
  2. 8.9.x core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/TestStateBasedSectionStorage.php \Drupal\layout_builder_test\Plugin\SectionStorage\TestStateBasedSectionStorage
  3. 11.x 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.

Hierarchy

Expanded class hierarchy of TestStateBasedSectionStorage

File

core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/TestStateBasedSectionStorage.php, line 16

Namespace

Drupal\layout_builder_test\Plugin\SectionStorage
View 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__);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ContextAwarePluginTrait::$context protected property The data objects representing the context of this plugin.
ContextAwarePluginTrait::getCacheContexts public function 10
ContextAwarePluginTrait::getCacheMaxAge public function 6
ContextAwarePluginTrait::getCacheTags public function 3
ContextAwarePluginTrait::getContext public function
ContextAwarePluginTrait::getContextDefinition public function
ContextAwarePluginTrait::getContextDefinitions public function
ContextAwarePluginTrait::getContextMapping public function 1
ContextAwarePluginTrait::getContexts public function
ContextAwarePluginTrait::getContextValue public function
ContextAwarePluginTrait::getContextValues public function
ContextAwarePluginTrait::getPluginDefinition abstract public function 1
ContextAwarePluginTrait::setContext public function 1
ContextAwarePluginTrait::setContextMapping public function
ContextAwarePluginTrait::setContextValue public function
ContextAwarePluginTrait::validateContexts public function
LayoutBuilderRoutesTrait::buildLayoutRoutes protected function Builds the layout routes for the given values.
PluginInspectionInterface::getPluginId public function Gets the plugin ID of the plugin instance. 2
SectionStorageBase::appendSection public function Appends a new section to the end of the list. Overrides SectionListInterface::appendSection
SectionStorageBase::count public function
SectionStorageBase::getContextsDuringPreview public function Gets contexts for use during preview. Overrides SectionStorageInterface::getContextsDuringPreview 2
SectionStorageBase::getSection public function Gets a domain object for the layout section. Overrides SectionListInterface::getSection
SectionStorageBase::getStorageType public function Returns the type of this storage. Overrides SectionStorageInterface::getStorageType
SectionStorageBase::getTempstoreKey public function Gets a string suitable for use as a tempstore key. Overrides TempStoreIdentifierInterface::getTempstoreKey 1
SectionStorageBase::insertSection public function Inserts a new section at a given delta. Overrides SectionListInterface::insertSection
SectionStorageBase::removeAllSections public function Removes all of the sections. Overrides SectionListInterface::removeAllSections
SectionStorageBase::removeSection public function Removes the section at the given delta. Overrides SectionListInterface::removeSection
TestStateBasedSectionStorage::access public function Overrides \Drupal\Core\Access\AccessibleInterface::access(). Overrides SectionStorageInterface::access
TestStateBasedSectionStorage::buildRoutes public function Provides the routes needed for Layout Builder UI. Overrides SectionStorageInterface::buildRoutes
TestStateBasedSectionStorage::deriveContextsFromRoute public function Derives the available plugin contexts from route values. Overrides SectionStorageInterface::deriveContextsFromRoute
TestStateBasedSectionStorage::extractIdFromRoute public function
TestStateBasedSectionStorage::getLayoutBuilderUrl public function Gets the URL used to display the Layout Builder UI. Overrides SectionStorageInterface::getLayoutBuilderUrl
TestStateBasedSectionStorage::getRedirectUrl public function Gets the URL used when redirecting away from the Layout Builder UI. Overrides SectionStorageInterface::getRedirectUrl
TestStateBasedSectionStorage::getSectionList protected function Gets the section list. Overrides SectionStorageBase::getSectionList
TestStateBasedSectionStorage::getSectionListFromId public function
TestStateBasedSectionStorage::getSections public function Gets the layout sections. Overrides SectionStorageBase::getSections
TestStateBasedSectionStorage::getStorageId public function Returns an identifier for this storage. Overrides SectionStorageInterface::getStorageId
TestStateBasedSectionStorage::isApplicable public function Determines if this section storage is applicable for the current contexts. Overrides SectionStorageInterface::isApplicable
TestStateBasedSectionStorage::label public function Gets the label for the object using the sections. Overrides SectionStorageInterface::label
TestStateBasedSectionStorage::save public function Saves the sections. Overrides SectionStorageInterface::save

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.