Skip to content
Snippets Groups Projects
Commit 86a1eb51 authored by Chandan Singh's avatar Chandan Singh Committed by Mark Fullmer
Browse files

Issue #3431601: Automated Drupal 11 compatibility fixes for layout_builder_styles

parent f1b89210
Branches 2.0.x
Tags 2.1.0
1 merge request!27Resolve #3431601 "Automated drupal 11"
Pipeline #290723 passed with warnings
name: Layout Builder Styles name: Layout Builder Styles
description: Apply styles to blocks in Layout Builder. 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 type: module
package: Layout Builder package: Layout Builder
dependencies: dependencies:
......
...@@ -122,6 +122,7 @@ function _layout_builder_styles_retrieve_by_type($type) { ...@@ -122,6 +122,7 @@ function _layout_builder_styles_retrieve_by_type($type) {
$query = \Drupal::entityTypeManager() $query = \Drupal::entityTypeManager()
->getStorage('layout_builder_style') ->getStorage('layout_builder_style')
->getQuery() ->getQuery()
->accessCheck(FALSE)
->condition('type', $type) ->condition('type', $type)
->sort('weight', 'ASC'); ->sort('weight', 'ASC');
$ids = $query->execute(); $ids = $query->execute();
...@@ -172,7 +173,7 @@ function _layout_builder_styles_add_style_selection_form_elements(array &$form, ...@@ -172,7 +173,7 @@ function _layout_builder_styles_add_style_selection_form_elements(array &$form,
// Import all groups, sorted by weight. // Import all groups, sorted by weight.
$group_storage = \Drupal::entityTypeManager()->getStorage('layout_builder_style_group'); $group_storage = \Drupal::entityTypeManager()->getStorage('layout_builder_style_group');
$query = $group_storage->getQuery(); $query = $group_storage->getQuery()->accessCheck(FALSE);
$query->sort('weight', 'ASC'); $query->sort('weight', 'ASC');
$groups = $query->execute(); $groups = $query->execute();
......
...@@ -43,7 +43,7 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface { ...@@ -43,7 +43,7 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function getSubscribedEvents() { public static function getSubscribedEvents(): array {
// Layout Builder also subscribes to this event to build the initial render // Layout Builder also subscribes to this event to build the initial render
// array. We use a higher weight so that we execute after it. // array. We use a higher weight so that we execute after it.
$events[LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAY] = [ $events[LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAY] = [
......
...@@ -153,8 +153,15 @@ class LayoutBuilderStyleForm extends EntityForm implements ContainerInjectionInt ...@@ -153,8 +153,15 @@ class LayoutBuilderStyleForm extends EntityForm implements ContainerInjectionInt
$blockDefinitions = $this->blockManager->getDefinitions(); $blockDefinitions = $this->blockManager->getDefinitions();
$blockDefinitions = $this->blockManager->getGroupedDefinitions($blockDefinitions); $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. // 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'])) { if (isset($blockDefinitions['Inline blocks'])) {
// Relabel the inline block type listing as generic "Custom block types". // Relabel the inline block type listing as generic "Custom block types".
......
...@@ -150,6 +150,12 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase { ...@@ -150,6 +150,12 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase {
public function testBlockRestrictions() { public function testBlockRestrictions() {
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
$page = $this->getSession()->getPage(); $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([ $block_node = $this->createNode([
'type' => 'bundle_with_section_field', 'type' => 'bundle_with_section_field',
...@@ -291,7 +297,7 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase { ...@@ -291,7 +297,7 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase {
$this->drupalGet($block_node->toUrl()); $this->drupalGet($block_node->toUrl());
$page->clickLink('Layout'); $page->clickLink('Layout');
$page->clickLink('Add block'); $page->clickLink('Add block');
$page->clickLink('Create custom block'); $page->clickLink($block_type_action_label);
$page->clickLink('Basic'); $page->clickLink('Basic');
// Basic block can use "Unrestricted" and "Basic only". // Basic block can use "Unrestricted" and "Basic only".
$assert_session->elementExists('css', 'select#edit-layout-builder-style-group option[value="basic_only"]'); $assert_session->elementExists('css', 'select#edit-layout-builder-style-group option[value="basic_only"]');
...@@ -303,7 +309,7 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase { ...@@ -303,7 +309,7 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase {
$this->drupalGet($block_node->toUrl()); $this->drupalGet($block_node->toUrl());
$page->clickLink('Layout'); $page->clickLink('Layout');
$page->clickLink('Add block'); $page->clickLink('Add block');
$page->clickLink('Create custom block'); $page->clickLink($block_type_action_label);
$page->clickLink('Alternate'); $page->clickLink('Alternate');
// Alternate block can use "Unrestricted" and "Alternate only". // Alternate block can use "Unrestricted" and "Alternate only".
$assert_session->elementNotExists('css', 'select#edit-layout-builder-style-group option[value="basic_only"]'); $assert_session->elementNotExists('css', 'select#edit-layout-builder-style-group option[value="basic_only"]');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment