diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module index 6c74976bea..cffd4e81c7 100644 --- a/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -40,10 +40,8 @@ function layout_builder_entity_type_alter(array &$entity_types) { } $entity_types['entity_view_display'] ->setClass(LayoutBuilderEntityViewDisplay::class) - ->setStorageClass(LayoutBuilderEntityViewDisplayStorage::class); - if (\Drupal::moduleHandler()->moduleExists('field_ui')) { - $entity_types['entity_view_display']->setFormClass('edit', LayoutBuilderEntityViewDisplayForm::class); - } + ->setStorageClass(LayoutBuilderEntityViewDisplayStorage::class) + ->setFormClass('edit', LayoutBuilderEntityViewDisplayForm::class); } /** diff --git a/core/modules/layout_builder/src/Controller/AddSectionController.php b/core/modules/layout_builder/src/Controller/AddSectionController.php index 947895985c..86fb545330 100644 --- a/core/modules/layout_builder/src/Controller/AddSectionController.php +++ b/core/modules/layout_builder/src/Controller/AddSectionController.php @@ -2,7 +2,6 @@ namespace Drupal\layout_builder\Controller; -use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\layout_builder\LayoutTempstoreRepositoryInterface; use Drupal\layout_builder\Section; @@ -32,12 +31,9 @@ class AddSectionController implements ContainerInjectionInterface { * * @param \Drupal\layout_builder\LayoutTempstoreRepositoryInterface $layout_tempstore_repository * The layout tempstore repository. - * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver - * The class resolver. */ - public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, ClassResolverInterface $class_resolver) { + public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository) { $this->layoutTempstoreRepository = $layout_tempstore_repository; - $this->classResolver = $class_resolver; } /** diff --git a/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php b/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php index 3fac020770..7478432fd7 100644 --- a/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php +++ b/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php @@ -15,11 +15,14 @@ trait LayoutRebuildTrait { /** - * The class resolver. + * Wraps the class resolver. * - * @var \Drupal\Core\DependencyInjection\ClassResolverInterface + * @return \Drupal\Core\DependencyInjection\ClassResolverInterface + * The class resolver. */ - protected $classResolver; + protected function classResolver() { + return \Drupal::classResolver(); + } /** * Rebuilds the layout. @@ -49,7 +52,7 @@ protected function rebuildAndClose(SectionStorageInterface $section_storage) { */ protected function rebuildLayout(SectionStorageInterface $section_storage) { $response = new AjaxResponse(); - $layout_controller = $this->classResolver->getInstanceFromDefinition(LayoutBuilderController::class); + $layout_controller = $this->classResolver()->getInstanceFromDefinition(LayoutBuilderController::class); $layout = $layout_controller->layout($section_storage, TRUE); $response->addCommand(new ReplaceCommand('#layout-builder', $layout)); return $response; diff --git a/core/modules/layout_builder/src/Controller/MoveBlockController.php b/core/modules/layout_builder/src/Controller/MoveBlockController.php index 7411aa0bbe..85d803feb5 100644 --- a/core/modules/layout_builder/src/Controller/MoveBlockController.php +++ b/core/modules/layout_builder/src/Controller/MoveBlockController.php @@ -2,7 +2,6 @@ namespace Drupal\layout_builder\Controller; -use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\layout_builder\LayoutTempstoreRepositoryInterface; use Drupal\layout_builder\SectionStorageInterface; @@ -29,12 +28,9 @@ class MoveBlockController implements ContainerInjectionInterface { * * @param \Drupal\layout_builder\LayoutTempstoreRepositoryInterface $layout_tempstore_repository * The layout tempstore repository. - * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver - * The class resolver. */ - public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, ClassResolverInterface $class_resolver) { + public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository) { $this->layoutTempstoreRepository = $layout_tempstore_repository; - $this->classResolver = $class_resolver; } /** @@ -42,8 +38,7 @@ public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore */ public static function create(ContainerInterface $container) { return new static( - $container->get('layout_builder.tempstore_repository'), - $container->get('class_resolver') + $container->get('layout_builder.tempstore_repository') ); } diff --git a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php index f84c74256d..7756a02cca 100644 --- a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php +++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php @@ -126,41 +126,6 @@ public function removeSection($delta) { return $this; } - /** - * {@inheritdoc} - */ - protected function urlRouteParameters($rel) { - $route_parameters = []; - if ($rel !== $this->getTargetEntityTypeId() . '.layout-builder') { - $route_parameters = parent::urlRouteParameters($rel); - } - - // @todo Move this to \Drupal\Core\Entity\EntityDisplayBase. - $entity_type = $this->entityTypeManager()->getDefinition($this->getTargetEntityTypeId()); - $bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle'; - $route_parameters[$bundle_parameter_key] = $this->getTargetBundle(); - return $route_parameters; - } - - /** - * {@inheritdoc} - */ - protected function linkTemplates() { - $link_templates = parent::linkTemplates(); - $link_templates[$this->getTargetEntityTypeId() . '.layout-builder'] = TRUE; - return $link_templates; - } - - /** - * {@inheritdoc} - */ - public function toUrl($rel = 'edit-form', array $options = []) { - if ($rel === 'layout-builder') { - $rel = $this->getTargetEntityTypeId() . '.' . $rel; - } - return parent::toUrl($rel, $options); - } - /** * {@inheritdoc} */ @@ -342,15 +307,31 @@ public function getStorageId() { * {@inheritdoc} */ public function getCanonicalUrl() { - $entity_type_id = $this->getTargetEntityTypeId(); - return Url::fromRoute("entity.entity_view_display.{$entity_type_id}.default", $this->urlRouteParameters('layout-builder')); + return Url::fromRoute("entity.entity_view_display.{$this->getTargetEntityTypeId()}.view_mode", $this->getRouteParameters()); } /** * {@inheritdoc} */ public function getLayoutBuilderUrl() { - return $this->toUrl('layout-builder'); + return Url::fromRoute("entity.entity_view_display.{$this->getTargetEntityTypeId()}.layout_builder", $this->getRouteParameters()); + } + + /** + * Returns the route parameters needed to build routes for this entity. + * + * @return string[] + * An array of route parameters. + */ + protected function getRouteParameters() { + $route_parameters = []; + + $entity_type = $this->entityTypeManager()->getDefinition($this->getTargetEntityTypeId()); + $bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle'; + $route_parameters[$bundle_parameter_key] = $this->getTargetBundle(); + + $route_parameters['view_mode_name'] = $this->getMode(); + return $route_parameters; } } diff --git a/core/modules/layout_builder/src/Form/AddBlockForm.php b/core/modules/layout_builder/src/Form/AddBlockForm.php index 83effd6226..f76a5cb2d8 100644 --- a/core/modules/layout_builder/src/Form/AddBlockForm.php +++ b/core/modules/layout_builder/src/Form/AddBlockForm.php @@ -2,8 +2,13 @@ namespace Drupal\layout_builder\Form; -use Drupal\layout_builder\Section; +use Drupal\Component\Uuid\UuidInterface; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\PluginFormFactoryInterface; +use Drupal\layout_builder\LayoutTempstoreRepositoryInterface; use Drupal\layout_builder\SectionComponent; +use Drupal\layout_builder\SectionStorageInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form to add a block. @@ -12,6 +17,39 @@ */ class AddBlockForm extends ConfigureBlockFormBase { + /** + * The UUID generator. + * + * @var \Drupal\Component\Uuid\UuidInterface + */ + protected $uuidGenerator; + + /** + * Constructs a new AddBlockForm. + * + * @param \Drupal\layout_builder\LayoutTempstoreRepositoryInterface $layout_tempstore_repository + * The layout tempstore repository. + * @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_manager + * The plugin form manager. + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator + * The UUID generator. + */ + public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, PluginFormFactoryInterface $plugin_form_manager, UuidInterface $uuid_generator) { + parent::__construct($layout_tempstore_repository, $plugin_form_manager); + $this->uuidGenerator = $uuid_generator; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('layout_builder.tempstore_repository'), + $container->get('plugin_form.factory'), + $container->get('uuid') + ); + } + /** * {@inheritdoc} */ @@ -27,10 +65,28 @@ protected function submitLabel() { } /** - * {@inheritdoc} + * Builds the form for the block. + * + * @param array $form + * An associative array containing the structure of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. + * @param \Drupal\layout_builder\SectionStorageInterface $section_storage + * The section storage being configured. + * @param int $delta + * The delta of the section. + * @param string $region + * The region of the block. + * @param string|null $plugin_id + * The plugin ID of the block to add. + * + * @return array + * The form array. */ - protected function submitBlock(Section $section, $region, $uuid, array $configuration) { - $section->appendComponent(new SectionComponent($uuid, $region, $configuration)); + public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, $region = NULL, $plugin_id = NULL) { + $component = new SectionComponent($this->uuidGenerator->generate(), $region, ['id' => $plugin_id]); + $section_storage->getSection($delta)->appendComponent($component); + return $this->doBuildForm($form, $form_state, $section_storage, $delta, $component); } } diff --git a/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php b/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php index c16f41ade8..f5245e567c 100644 --- a/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php +++ b/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php @@ -2,14 +2,10 @@ namespace Drupal\layout_builder\Form; -use Drupal\Component\Uuid\UuidInterface; -use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Block\BlockPluginInterface; -use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\SubformState; -use Drupal\Core\Plugin\Context\ContextRepositoryInterface; use Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait; use Drupal\Core\Plugin\ContextAwarePluginInterface; use Drupal\Core\Plugin\PluginFormFactoryInterface; @@ -17,7 +13,7 @@ use Drupal\layout_builder\Context\LayoutBuilderContextTrait; use Drupal\layout_builder\Controller\LayoutRebuildTrait; use Drupal\layout_builder\LayoutTempstoreRepositoryInterface; -use Drupal\layout_builder\Section; +use Drupal\layout_builder\SectionComponent; use Drupal\layout_builder\SectionStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -40,13 +36,6 @@ */ protected $block; - /** - * The context repository. - * - * @var \Drupal\Core\Plugin\Context\ContextRepositoryInterface - */ - protected $contextRepository; - /** * The layout tempstore repository. * @@ -54,20 +43,6 @@ */ protected $layoutTempstoreRepository; - /** - * The block manager. - * - * @var \Drupal\Core\Block\BlockManagerInterface - */ - protected $blockManager; - - /** - * The UUID generator. - * - * @var \Drupal\Component\Uuid\UuidInterface - */ - protected $uuid; - /** * The plugin form manager. * @@ -76,19 +51,12 @@ protected $pluginFormFactory; /** - * The field delta. + * The section delta. * * @var int */ protected $delta; - /** - * The current region. - * - * @var string - */ - protected $region; - /** * The section storage. * @@ -96,28 +64,23 @@ */ protected $sectionStorage; + /** + * The UUID of the component. + * + * @var string + */ + protected $uuid; + /** * Constructs a new block form. * * @param \Drupal\layout_builder\LayoutTempstoreRepositoryInterface $layout_tempstore_repository * The layout tempstore repository. - * @param \Drupal\Core\Plugin\Context\ContextRepositoryInterface $context_repository - * The context repository. - * @param \Drupal\Core\Block\BlockManagerInterface $block_manager - * The block manager. - * @param \Drupal\Component\Uuid\UuidInterface $uuid - * The UUID generator. - * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver - * The class resolver. * @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_manager * The plugin form manager. */ - public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, ContextRepositoryInterface $context_repository, BlockManagerInterface $block_manager, UuidInterface $uuid, ClassResolverInterface $class_resolver, PluginFormFactoryInterface $plugin_form_manager) { + public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, PluginFormFactoryInterface $plugin_form_manager) { $this->layoutTempstoreRepository = $layout_tempstore_repository; - $this->contextRepository = $context_repository; - $this->blockManager = $block_manager; - $this->uuid = $uuid; - $this->classResolver = $class_resolver; $this->pluginFormFactory = $plugin_form_manager; } @@ -127,33 +90,10 @@ public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore public static function create(ContainerInterface $container) { return new static( $container->get('layout_builder.tempstore_repository'), - $container->get('context.repository'), - $container->get('plugin.manager.block'), - $container->get('uuid'), - $container->get('class_resolver'), $container->get('plugin_form.factory') ); } - /** - * Prepares the block plugin based on the block ID. - * - * @param string $block_id - * Either a block ID, or the plugin ID used to create a new block. - * @param array $configuration - * The block configuration. - * - * @return \Drupal\Core\Block\BlockPluginInterface - * The block plugin. - */ - protected function prepareBlock($block_id, array $configuration) { - if (!isset($configuration['uuid'])) { - $configuration['uuid'] = $this->uuid->generate(); - } - - return $this->blockManager->createInstance($block_id, $configuration); - } - /** * Builds the form for the block. * @@ -165,23 +105,20 @@ protected function prepareBlock($block_id, array $configuration) { * The section storage being configured. * @param int $delta * The delta of the section. - * @param string $region - * The region of the block. - * @param string|null $plugin_id - * The plugin ID of the block to add. - * @param array $configuration - * (optional) The array of configuration for the block. + * @param \Drupal\layout_builder\SectionComponent $component + * The section component containing the block. * * @return array * The form array. */ - public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, $region = NULL, $plugin_id = NULL, array $configuration = []) { + public function doBuildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, SectionComponent $component = NULL) { $this->sectionStorage = $section_storage; $this->delta = $delta; - $this->region = $region; - $this->block = $this->prepareBlock($plugin_id, $configuration); + $this->uuid = $component->getUuid(); - $form_state->setTemporaryValue('gathered_contexts', $this->getAvailableContexts($section_storage)); + $contexts = $this->getAvailableContexts($section_storage); + $form_state->setTemporaryValue('gathered_contexts', $contexts); + $this->block = $component->getPlugin($contexts); // @todo Remove once https://www.drupal.org/node/2268787 is resolved. $form_state->set('block_theme', $this->config('system.theme')->get('default')); @@ -211,20 +148,6 @@ public function buildForm(array $form, FormStateInterface $form_state, SectionSt */ abstract protected function submitLabel(); - /** - * Handles the submission of a block. - * - * @param \Drupal\layout_builder\Section $section - * The layout section. - * @param string $region - * The region name. - * @param string $uuid - * The UUID of the block. - * @param array $configuration - * The block configuration. - */ - abstract protected function submitBlock(Section $section, $region, $uuid, array $configuration); - /** * {@inheritdoc} */ @@ -249,7 +172,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $configuration = $this->block->getConfiguration(); $section = $this->sectionStorage->getSection($this->delta); - $this->submitBlock($section, $this->region, $configuration['uuid'], $configuration); + $section->getComponent($this->uuid)->setConfiguration($configuration); $this->layoutTempstoreRepository->set($this->sectionStorage); $form_state->setRedirectUrl($this->sectionStorage->getLayoutBuilderUrl()); diff --git a/core/modules/layout_builder/src/Form/ConfigureSectionForm.php b/core/modules/layout_builder/src/Form/ConfigureSectionForm.php index 2bfcdca7c2..cba7633390 100644 --- a/core/modules/layout_builder/src/Form/ConfigureSectionForm.php +++ b/core/modules/layout_builder/src/Form/ConfigureSectionForm.php @@ -2,7 +2,6 @@ namespace Drupal\layout_builder\Form; -use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\SubformState; @@ -73,14 +72,11 @@ class ConfigureSectionForm extends FormBase { * * @param \Drupal\layout_builder\LayoutTempstoreRepositoryInterface $layout_tempstore_repository * The layout tempstore repository. - * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver - * The class resolver. * @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_manager * The plugin form manager. */ - public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, ClassResolverInterface $class_resolver, PluginFormFactoryInterface $plugin_form_manager) { + public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, PluginFormFactoryInterface $plugin_form_manager) { $this->layoutTempstoreRepository = $layout_tempstore_repository; - $this->classResolver = $class_resolver; $this->pluginFormFactory = $plugin_form_manager; } @@ -90,7 +86,6 @@ public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore public static function create(ContainerInterface $container) { return new static( $container->get('layout_builder.tempstore_repository'), - $container->get('class_resolver'), $container->get('plugin_form.factory') ); } diff --git a/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php b/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php index 511a11968e..0575a35fa5 100644 --- a/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php +++ b/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php @@ -2,7 +2,6 @@ namespace Drupal\layout_builder\Form; -use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\layout_builder\Controller\LayoutRebuildTrait; @@ -46,12 +45,9 @@ * * @param \Drupal\layout_builder\LayoutTempstoreRepositoryInterface $layout_tempstore_repository * The layout tempstore repository. - * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver - * The class resolver. */ - public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, ClassResolverInterface $class_resolver) { + public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository) { $this->layoutTempstoreRepository = $layout_tempstore_repository; - $this->classResolver = $class_resolver; } /** @@ -59,8 +55,7 @@ public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore */ public static function create(ContainerInterface $container) { return new static( - $container->get('layout_builder.tempstore_repository'), - $container->get('class_resolver') + $container->get('layout_builder.tempstore_repository') ); } diff --git a/core/modules/layout_builder/src/Form/UpdateBlockForm.php b/core/modules/layout_builder/src/Form/UpdateBlockForm.php index afca0d25c9..c00b406eb2 100644 --- a/core/modules/layout_builder/src/Form/UpdateBlockForm.php +++ b/core/modules/layout_builder/src/Form/UpdateBlockForm.php @@ -2,9 +2,7 @@ namespace Drupal\layout_builder\Form; -use Drupal\Component\Plugin\ConfigurablePluginInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\layout_builder\Section; use Drupal\layout_builder\SectionStorageInterface; /** @@ -36,19 +34,13 @@ public function getFormId() { * The region of the block. * @param string $uuid * The UUID of the block being updated. - * @param array $configuration - * (optional) The array of configuration for the block. * * @return array * The form array. */ - public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, $region = NULL, $uuid = NULL, array $configuration = []) { - $plugin = $section_storage->getSection($delta)->getComponent($uuid)->getPlugin(); - if ($plugin instanceof ConfigurablePluginInterface) { - $configuration = $plugin->getConfiguration(); - } - - return parent::buildForm($form, $form_state, $section_storage, $delta, $region, $plugin->getPluginId(), $configuration); + public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, $region = NULL, $uuid = NULL) { + $component = $section_storage->getSection($delta)->getComponent($uuid); + return $this->doBuildForm($form, $form_state, $section_storage, $delta, $component); } /** @@ -58,11 +50,4 @@ protected function submitLabel() { return $this->t('Update'); } - /** - * {@inheritdoc} - */ - protected function submitBlock(Section $section, $region, $uuid, array $configuration) { - $section->getComponent($uuid)->setConfiguration($configuration); - } - } diff --git a/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php b/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php index d9c3d8beb0..c393b24fd1 100644 --- a/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php +++ b/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php @@ -86,11 +86,10 @@ public function onAlterRoutes(RouteBuildEvent $event) { if (!$entity_route = $collection->get($route_name)) { continue; } - $path = $entity_route->getPath() . '/display-layout'; + $path = $entity_route->getPath() . '/display-layout/{view_mode_name}'; $defaults = []; $defaults['entity_type_id'] = $entity_type_id; - $defaults['view_mode_name'] = 'default'; // If the entity type has no bundles and it doesn't use {bundle} in its // admin path, use the entity type. if (strpos($path, '{bundle}') === FALSE) { diff --git a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php index 1d638303ab..5e405bbca0 100644 --- a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php +++ b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php @@ -42,6 +42,7 @@ protected function setUp() { $this->installEntitySchema('entity_test_base_field_display'); $this->installConfig(['filter']); + $this->installSchema('system', ['key_value_expire']); // Set up a non-admin user that is allowed to view test entities. \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity'])); diff --git a/core/modules/layout_builder/tests/src/Kernel/SectionStorageTestBase.php b/core/modules/layout_builder/tests/src/Kernel/SectionStorageTestBase.php index 97c1fba713..173ad90153 100644 --- a/core/modules/layout_builder/tests/src/Kernel/SectionStorageTestBase.php +++ b/core/modules/layout_builder/tests/src/Kernel/SectionStorageTestBase.php @@ -20,6 +20,7 @@ 'layout_test', 'user', 'entity_test', + 'system', ]; /** @@ -35,6 +36,8 @@ protected function setUp() { parent::setUp(); + $this->installSchema('system', ['key_value_expire']); + $section_data = [ new Section('layout_test_plugin', [], [ 'first-uuid' => new SectionComponent('first-uuid', 'content'), diff --git a/core/modules/layout_builder/tests/src/Unit/LayoutBuilderRoutesTest.php b/core/modules/layout_builder/tests/src/Unit/LayoutBuilderRoutesTest.php index 0d19b2bab0..e47448c177 100644 --- a/core/modules/layout_builder/tests/src/Unit/LayoutBuilderRoutesTest.php +++ b/core/modules/layout_builder/tests/src/Unit/LayoutBuilderRoutesTest.php @@ -417,10 +417,9 @@ public function testOnAlterRoutes() { 'known' => new Route('/admin/entity/whatever'), 'with_bundle' => new Route('/admin/entity/{bundle}'), 'entity.entity_view_display.with_field_ui_route.layout_builder' => new Route( - '/admin/entity/whatever/display-layout', + '/admin/entity/whatever/display-layout/{view_mode_name}', [ 'entity_type_id' => 'with_field_ui_route', - 'view_mode_name' => 'default', 'bundle' => 'with_field_ui_route', 'section_storage_type' => 'defaults', 'section_storage' => '', @@ -437,13 +436,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_field_ui_route.layout_builder_save' => new Route( - '/admin/entity/whatever/display-layout/save', + '/admin/entity/whatever/display-layout/{view_mode_name}/save', [ 'entity_type_id' => 'with_field_ui_route', - 'view_mode_name' => 'default', 'bundle' => 'with_field_ui_route', 'section_storage_type' => 'defaults', 'section_storage' => '', @@ -458,13 +457,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_field_ui_route.layout_builder_cancel' => new Route( - '/admin/entity/whatever/display-layout/cancel', + '/admin/entity/whatever/display-layout/{view_mode_name}/cancel', [ 'entity_type_id' => 'with_field_ui_route', - 'view_mode_name' => 'default', 'bundle' => 'with_field_ui_route', 'section_storage_type' => 'defaults', 'section_storage' => '', @@ -479,13 +478,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_bundle_key.layout_builder' => new Route( - '/admin/entity/whatever/display-layout', + '/admin/entity/whatever/display-layout/{view_mode_name}', [ 'entity_type_id' => 'with_bundle_key', - 'view_mode_name' => 'default', 'bundle_key' => 'my_bundle_type', 'section_storage_type' => 'defaults', 'section_storage' => '', @@ -502,13 +501,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_bundle_key.layout_builder_save' => new Route( - '/admin/entity/whatever/display-layout/save', + '/admin/entity/whatever/display-layout/{view_mode_name}/save', [ 'entity_type_id' => 'with_bundle_key', - 'view_mode_name' => 'default', 'bundle_key' => 'my_bundle_type', 'section_storage_type' => 'defaults', 'section_storage' => '', @@ -523,13 +522,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_bundle_key.layout_builder_cancel' => new Route( - '/admin/entity/whatever/display-layout/cancel', + '/admin/entity/whatever/display-layout/{view_mode_name}/cancel', [ 'entity_type_id' => 'with_bundle_key', - 'view_mode_name' => 'default', 'bundle_key' => 'my_bundle_type', 'section_storage_type' => 'defaults', 'section_storage' => '', @@ -544,13 +543,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_bundle_parameter.layout_builder' => new Route( - '/admin/entity/{bundle}/display-layout', + '/admin/entity/{bundle}/display-layout/{view_mode_name}', [ 'entity_type_id' => 'with_bundle_parameter', - 'view_mode_name' => 'default', 'section_storage_type' => 'defaults', 'section_storage' => '', 'is_rebuilding' => FALSE, @@ -566,13 +565,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_bundle_parameter.layout_builder_save' => new Route( - '/admin/entity/{bundle}/display-layout/save', + '/admin/entity/{bundle}/display-layout/{view_mode_name}/save', [ 'entity_type_id' => 'with_bundle_parameter', - 'view_mode_name' => 'default', 'section_storage_type' => 'defaults', 'section_storage' => '', '_controller' => '\Drupal\layout_builder\Controller\LayoutBuilderController::saveLayout', @@ -586,13 +585,13 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), 'entity.entity_view_display.with_bundle_parameter.layout_builder_cancel' => new Route( - '/admin/entity/{bundle}/display-layout/cancel', + '/admin/entity/{bundle}/display-layout/{view_mode_name}/cancel', [ 'entity_type_id' => 'with_bundle_parameter', - 'view_mode_name' => 'default', 'section_storage_type' => 'defaults', 'section_storage' => '', '_controller' => '\Drupal\layout_builder\Controller\LayoutBuilderController::cancelLayout', @@ -606,6 +605,7 @@ public function testOnAlterRoutes() { 'section_storage' => ['layout_builder_tempstore' => TRUE], ], '_layout_builder' => TRUE, + '_admin_route' => FALSE, ] ), ];