diff --git a/layout_builder_styles.info.yml b/layout_builder_styles.info.yml index 170cdaea284ce22a68b0be77e9dccc9099bfe937..0e257f086f1e11d8cd05c5e93f621a68ea93c4fa 100644 --- a/layout_builder_styles.info.yml +++ b/layout_builder_styles.info.yml @@ -1,6 +1,6 @@ name: Layout Builder Styles description: Apply styles to blocks in Layout Builder. -core_version_requirement: ^8.7.7 || ^9 || ^10 +core_version_requirement: ^8.7.7 || ^9 || ^10 || ^11 type: module package: Layout Builder dependencies: diff --git a/layout_builder_styles.module b/layout_builder_styles.module index 99d83f14f5dc18708f991c3744d515dcfe46ad39..08f70082187181218ac538e109502337354d703e 100644 --- a/layout_builder_styles.module +++ b/layout_builder_styles.module @@ -122,6 +122,7 @@ function _layout_builder_styles_retrieve_by_type($type) { $query = \Drupal::entityTypeManager() ->getStorage('layout_builder_style') ->getQuery() + ->accessCheck(FALSE) ->condition('type', $type) ->sort('weight', 'ASC'); $ids = $query->execute(); @@ -172,7 +173,7 @@ function _layout_builder_styles_add_style_selection_form_elements(array &$form, // Import all groups, sorted by weight. $group_storage = \Drupal::entityTypeManager()->getStorage('layout_builder_style_group'); - $query = $group_storage->getQuery(); + $query = $group_storage->getQuery()->accessCheck(FALSE); $query->sort('weight', 'ASC'); $groups = $query->execute(); diff --git a/src/EventSubscriber/BlockComponentRenderArraySubscriber.php b/src/EventSubscriber/BlockComponentRenderArraySubscriber.php index 842b00ba59d856c27a41faeeb40c0946b0fb97b3..0f6165e36dbfa56e068a60fea9e70cdf2eaf114f 100644 --- a/src/EventSubscriber/BlockComponentRenderArraySubscriber.php +++ b/src/EventSubscriber/BlockComponentRenderArraySubscriber.php @@ -43,7 +43,7 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { + public static function getSubscribedEvents(): array { // Layout Builder also subscribes to this event to build the initial render // array. We use a higher weight so that we execute after it. $events[LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAY] = [ diff --git a/src/Form/LayoutBuilderStyleForm.php b/src/Form/LayoutBuilderStyleForm.php index ae839edd82b1218dea8004248c8877ff2655d038..c911463394d46707a58fb2005e10b66ae4a83fb9 100644 --- a/src/Form/LayoutBuilderStyleForm.php +++ b/src/Form/LayoutBuilderStyleForm.php @@ -153,8 +153,15 @@ class LayoutBuilderStyleForm extends EntityForm implements ContainerInjectionInt $blockDefinitions = $this->blockManager->getDefinitions(); $blockDefinitions = $this->blockManager->getGroupedDefinitions($blockDefinitions); + // As per CR - https://www.drupal.org/node/3320855 + // changed the definition from custom to content. // Remove individual reusable blocks from list. - unset($blockDefinitions['Custom']); + if (version_compare(\Drupal::VERSION, '10.1.0', '>=')) { + unset($blockDefinitions['Content block']); + } + else { + unset($blockDefinitions['Custom']); + } if (isset($blockDefinitions['Inline blocks'])) { // Relabel the inline block type listing as generic "Custom block types". diff --git a/tests/src/Functional/LayoutBuilderStyleRestrictionsTest.php b/tests/src/Functional/LayoutBuilderStyleRestrictionsTest.php index 2bd48eec9ce050a61e46af5980e870a8ad87e7f2..f942e35d62619b889a6afd5e16029c48fa2efb98 100644 --- a/tests/src/Functional/LayoutBuilderStyleRestrictionsTest.php +++ b/tests/src/Functional/LayoutBuilderStyleRestrictionsTest.php @@ -150,6 +150,12 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase { public function testBlockRestrictions() { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); + $block_type_action_label = 'Create custom block'; + // As per CR - https://www.drupal.org/node/3320855 + // changed the action label from custom to content. + if (version_compare(\Drupal::VERSION, '10.1.0', '>=')) { + $block_type_action_label = 'Create content block'; + } $block_node = $this->createNode([ 'type' => 'bundle_with_section_field', @@ -291,7 +297,7 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase { $this->drupalGet($block_node->toUrl()); $page->clickLink('Layout'); $page->clickLink('Add block'); - $page->clickLink('Create custom block'); + $page->clickLink($block_type_action_label); $page->clickLink('Basic'); // Basic block can use "Unrestricted" and "Basic only". $assert_session->elementExists('css', 'select#edit-layout-builder-style-group option[value="basic_only"]'); @@ -303,7 +309,7 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase { $this->drupalGet($block_node->toUrl()); $page->clickLink('Layout'); $page->clickLink('Add block'); - $page->clickLink('Create custom block'); + $page->clickLink($block_type_action_label); $page->clickLink('Alternate'); // Alternate block can use "Unrestricted" and "Alternate only". $assert_session->elementNotExists('css', 'select#edit-layout-builder-style-group option[value="basic_only"]');