Skip to content
Snippets Groups Projects
Commit e3873ccd authored by Angie Byron's avatar Angie Byron
Browse files

Issue #3096034 by tim.plunkett, zrpnr: Allow customization of the list of layouts

parent 7732e9d7
No related branches found
No related tags found
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards
...@@ -69,8 +69,8 @@ public function build(SectionStorageInterface $section_storage, $delta) { ...@@ -69,8 +69,8 @@ public function build(SectionStorageInterface $section_storage, $delta) {
$item = [ $item = [
'#type' => 'link', '#type' => 'link',
'#title' => [ '#title' => [
$definition->getIcon(60, 80, 1, 3), 'icon' => $definition->getIcon(60, 80, 1, 3),
[ 'label' => [
'#type' => 'container', '#type' => 'container',
'#children' => $definition->getLabel(), '#children' => $definition->getLabel(),
], ],
...@@ -90,10 +90,10 @@ public function build(SectionStorageInterface $section_storage, $delta) { ...@@ -90,10 +90,10 @@ public function build(SectionStorageInterface $section_storage, $delta) {
$item['#attributes']['data-dialog-type'][] = 'dialog'; $item['#attributes']['data-dialog-type'][] = 'dialog';
$item['#attributes']['data-dialog-renderer'][] = 'off_canvas'; $item['#attributes']['data-dialog-renderer'][] = 'off_canvas';
} }
$items[] = $item; $items[$plugin_id] = $item;
} }
$output['layouts'] = [ $output['layouts'] = [
'#theme' => 'item_list', '#theme' => 'item_list__layouts',
'#items' => $items, '#items' => $items,
'#attributes' => [ '#attributes' => [
'class' => [ 'class' => [
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
/** /**
* @file * @file
* For testing Field Block theme suggestions. * For testing theme suggestions.
*/ */
/** /**
* Implements hook_theme(). * Implements hook_theme().
*/ */
function layout_builder_field_block_theme_suggestions_test_theme() { function layout_builder_theme_suggestions_test_theme() {
// It is necessary to explicitly register the template via hook_theme() // It is necessary to explicitly register the template via hook_theme()
// because it is added via a module, not a theme. // because it is added via a module, not a theme.
return [ return [
...@@ -17,3 +17,14 @@ function layout_builder_field_block_theme_suggestions_test_theme() { ...@@ -17,3 +17,14 @@ function layout_builder_field_block_theme_suggestions_test_theme() {
], ],
]; ];
} }
/**
* Implements hook_preprocess_HOOK() for the list of layouts.
*/
function layout_builder_theme_suggestions_test_preprocess_item_list__layouts(&$variables) {
foreach (array_keys($variables['items']) as $layout_id) {
if (isset($variables['items'][$layout_id]['value']['#title']['icon'])) {
$variables['items'][$layout_id]['value']['#title']['icon'] = ['#markup' => __FUNCTION__];
}
}
}
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
* Tests field block template suggestions. * Tests template suggestions.
* *
* @group layout_builder * @group layout_builder
*/ */
class LayoutBuilderFieldBlockThemeSuggestionsTest extends BrowserTestBase { class LayoutBuilderThemeSuggestionsTest extends BrowserTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -17,7 +17,7 @@ class LayoutBuilderFieldBlockThemeSuggestionsTest extends BrowserTestBase { ...@@ -17,7 +17,7 @@ class LayoutBuilderFieldBlockThemeSuggestionsTest extends BrowserTestBase {
public static $modules = [ public static $modules = [
'layout_builder', 'layout_builder',
'node', 'node',
'layout_builder_field_block_theme_suggestions_test', 'layout_builder_theme_suggestions_test',
]; ];
/** /**
...@@ -54,6 +54,18 @@ protected function setUp() { ...@@ -54,6 +54,18 @@ protected function setUp() {
$this->drupalPostForm(NULL, ['layout[enabled]' => TRUE], 'Save'); $this->drupalPostForm(NULL, ['layout[enabled]' => TRUE], 'Save');
} }
/**
* Tests alterations of the layout list via preprocess functions.
*/
public function testLayoutListSuggestion() {
$page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
$this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default/layout');
$page->clickLink('Add section');
$assert_session->pageTextContains('layout_builder_theme_suggestions_test_preprocess_item_list__layouts');
}
/** /**
* Tests that of view mode specific field templates are suggested. * Tests that of view mode specific field templates are suggested.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment