- Issue created by @ccjjmartin
When attempting to add a new section that was previously restricted to the default layout for a content type I find that the site is stuck in an endless loop of (see steps below). Of note, this happens when using Drupal core 11.0.5 and layout_builder_restrictions 3.0.0.
Somewhere in the layout_builder_restrictions/src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php file there is an issue. When I comment out the changes to the $definitions variable I am able to see all of the sections add the section I need and then save the configuration but the new section that should be enabled is still lost after saving the section.
/**
* {@inheritdoc}
*/
public function alterSectionDefinitions(array $definitions, array $context) {
// Respect restrictions on allowed layouts specified by section storage.
if (isset($context['section_storage'])) {
$default = $context['section_storage'] instanceof OverridesSectionStorageInterface ? $context['section_storage']->getDefaultSectionStorage() : $context['section_storage'];
if ($default instanceof ThirdPartySettingsInterface) {
$third_party_settings = $default->getThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction', []);
$allowed_layouts = (isset($third_party_settings['allowed_layouts'])) ? $third_party_settings['allowed_layouts'] : [];
// Filter blocks from entity-specific SectionStorage (i.e., UI).
if (!empty($allowed_layouts)) {
$definitions = array_intersect_key($definitions, array_flip($allowed_layouts));
}
}
}
return $definitions;
}
Active
3.0
Code