function SectionStorageBase::getContextsDuringPreview
Gets contexts for use during preview.
When not in preview, ::getContexts() will be used.
Return value
\Drupal\Core\Plugin\Context\ContextInterface[] The plugin contexts suitable for previewing.
Overrides SectionStorageInterface::getContextsDuringPreview
2 calls to SectionStorageBase::getContextsDuringPreview()
- DefaultsSectionStorage::getContextsDuringPreview in core/modules/ layout_builder/ src/ Plugin/ SectionStorage/ DefaultsSectionStorage.php 
- Gets contexts for use during preview.
- OverridesSectionStorage::getContextsDuringPreview in core/modules/ layout_builder/ src/ Plugin/ SectionStorage/ OverridesSectionStorage.php 
- Gets contexts for use during preview.
2 methods override SectionStorageBase::getContextsDuringPreview()
- DefaultsSectionStorage::getContextsDuringPreview in core/modules/ layout_builder/ src/ Plugin/ SectionStorage/ DefaultsSectionStorage.php 
- Gets contexts for use during preview.
- OverridesSectionStorage::getContextsDuringPreview in core/modules/ layout_builder/ src/ Plugin/ SectionStorage/ OverridesSectionStorage.php 
- Gets contexts for use during preview.
File
- 
              core/modules/ layout_builder/ src/ Plugin/ SectionStorage/ SectionStorageBase.php, line 95 
Class
- SectionStorageBase
- Provides a base class for Section Storage types.
Namespace
Drupal\layout_builder\Plugin\SectionStorageCode
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;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
