Loading core/modules/layout_builder/src/DefaultsSectionStorageInterface.php +1 −1 Original line number Diff line number Diff line Loading @@ -7,4 +7,4 @@ /** * Defines an interface for an object that stores layout sections for defaults. */ interface DefaultsSectionStorageInterface extends SectionStorageInterface, ThirdPartySettingsInterface, LayoutBuilderEnabledInterface, LayoutBuilderOverridableInterface {} interface DefaultsSectionStorageInterface extends SupportAwareSectionStorageInterface, ThirdPartySettingsInterface, LayoutBuilderEnabledInterface, LayoutBuilderOverridableInterface {} core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ use Drupal\layout_builder\Section; use Drupal\layout_builder\SectionComponent; use Drupal\layout_builder\SectionListTrait; use Drupal\layout_builder\SectionStorage\SupportAwareSectionStorageManagerInterface; /** * Provides an entity view display entity that has a layout. Loading Loading @@ -300,7 +301,11 @@ public function buildMultiple(array $entities) { return $build_list; } $sectionStorageManager = $this->sectionStorageManager(); foreach ($entities as $id => $entity) { if ($sectionStorageManager instanceof SupportAwareSectionStorageManagerInterface && $sectionStorageManager->notSupported($entity->getEntityTypeId(), $entity->bundle(), $this->mode)) { continue; } $build_list[$id]['_layout_builder'] = $this->buildSections($entity); // If there are any sections, remove all fields with configurable display Loading core/modules/layout_builder/src/OverridesSectionStorageInterface.php +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ /** * Defines an interface for an object that stores layout sections for overrides. */ interface OverridesSectionStorageInterface extends SectionStorageInterface { interface OverridesSectionStorageInterface extends SupportAwareSectionStorageInterface { /** * Returns the corresponding defaults section storage for this override. Loading core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php +12 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ use Drupal\layout_builder\Attribute\SectionStorage; use Drupal\layout_builder\DefaultsSectionStorageInterface; use Drupal\layout_builder\Entity\SampleEntityGeneratorInterface; use Drupal\layout_builder\LayoutBuilderEnabledInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\RouteCollection; Loading Loading @@ -413,4 +414,15 @@ public function setContext($name, ComponentContextInterface $context) { parent::setContext($name, $context); } /** * {@inheritdoc} */ public function isSupported(string $entity_type_id, string $bundle, string $view_mode): bool { $id = "$entity_type_id.$bundle.$view_mode"; $storage = $this->entityTypeManager->getStorage('entity_view_display'); $display = $storage->load($id) ?? $storage->load("$entity_type_id.$bundle.default"); return $display instanceof LayoutBuilderEnabledInterface && $display->isLayoutBuilderEnabled(); } } core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php +16 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ use Drupal\Core\Url; use Drupal\layout_builder\Attribute\SectionStorage; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface; use Drupal\layout_builder\LayoutEntityHelperTrait; use Drupal\layout_builder\OverridesSectionStorageInterface; use Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface; Loading Loading @@ -402,4 +403,19 @@ public function isOverridden() { return !empty($this->getSections()); } /** * {@inheritdoc} */ public function isSupported(string $entity_type_id, string $bundle, string $view_mode): bool { // Layout builder currently only supports the default view mode. // @see https://www.drupal.org/node/2907413 if ($view_mode !== 'default') { return FALSE; } $id = "$entity_type_id.$bundle.$view_mode"; $storage = $this->entityTypeManager->getStorage('entity_view_display'); $display = $storage->load($id); return $display instanceof LayoutEntityDisplayInterface && $display->isOverridable(); } } Loading
core/modules/layout_builder/src/DefaultsSectionStorageInterface.php +1 −1 Original line number Diff line number Diff line Loading @@ -7,4 +7,4 @@ /** * Defines an interface for an object that stores layout sections for defaults. */ interface DefaultsSectionStorageInterface extends SectionStorageInterface, ThirdPartySettingsInterface, LayoutBuilderEnabledInterface, LayoutBuilderOverridableInterface {} interface DefaultsSectionStorageInterface extends SupportAwareSectionStorageInterface, ThirdPartySettingsInterface, LayoutBuilderEnabledInterface, LayoutBuilderOverridableInterface {}
core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ use Drupal\layout_builder\Section; use Drupal\layout_builder\SectionComponent; use Drupal\layout_builder\SectionListTrait; use Drupal\layout_builder\SectionStorage\SupportAwareSectionStorageManagerInterface; /** * Provides an entity view display entity that has a layout. Loading Loading @@ -300,7 +301,11 @@ public function buildMultiple(array $entities) { return $build_list; } $sectionStorageManager = $this->sectionStorageManager(); foreach ($entities as $id => $entity) { if ($sectionStorageManager instanceof SupportAwareSectionStorageManagerInterface && $sectionStorageManager->notSupported($entity->getEntityTypeId(), $entity->bundle(), $this->mode)) { continue; } $build_list[$id]['_layout_builder'] = $this->buildSections($entity); // If there are any sections, remove all fields with configurable display Loading
core/modules/layout_builder/src/OverridesSectionStorageInterface.php +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ /** * Defines an interface for an object that stores layout sections for overrides. */ interface OverridesSectionStorageInterface extends SectionStorageInterface { interface OverridesSectionStorageInterface extends SupportAwareSectionStorageInterface { /** * Returns the corresponding defaults section storage for this override. Loading
core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php +12 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ use Drupal\layout_builder\Attribute\SectionStorage; use Drupal\layout_builder\DefaultsSectionStorageInterface; use Drupal\layout_builder\Entity\SampleEntityGeneratorInterface; use Drupal\layout_builder\LayoutBuilderEnabledInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\RouteCollection; Loading Loading @@ -413,4 +414,15 @@ public function setContext($name, ComponentContextInterface $context) { parent::setContext($name, $context); } /** * {@inheritdoc} */ public function isSupported(string $entity_type_id, string $bundle, string $view_mode): bool { $id = "$entity_type_id.$bundle.$view_mode"; $storage = $this->entityTypeManager->getStorage('entity_view_display'); $display = $storage->load($id) ?? $storage->load("$entity_type_id.$bundle.default"); return $display instanceof LayoutBuilderEnabledInterface && $display->isLayoutBuilderEnabled(); } }
core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php +16 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ use Drupal\Core\Url; use Drupal\layout_builder\Attribute\SectionStorage; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface; use Drupal\layout_builder\LayoutEntityHelperTrait; use Drupal\layout_builder\OverridesSectionStorageInterface; use Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface; Loading Loading @@ -402,4 +403,19 @@ public function isOverridden() { return !empty($this->getSections()); } /** * {@inheritdoc} */ public function isSupported(string $entity_type_id, string $bundle, string $view_mode): bool { // Layout builder currently only supports the default view mode. // @see https://www.drupal.org/node/2907413 if ($view_mode !== 'default') { return FALSE; } $id = "$entity_type_id.$bundle.$view_mode"; $storage = $this->entityTypeManager->getStorage('entity_view_display'); $display = $storage->load($id); return $display instanceof LayoutEntityDisplayInterface && $display->isOverridable(); } }