diff --git a/core/modules/layout_builder/layout_builder.routing.yml b/core/modules/layout_builder/layout_builder.routing.yml index 222600d..0bc6d3c 100644 --- a/core/modules/layout_builder/layout_builder.routing.yml +++ b/core/modules/layout_builder/layout_builder.routing.yml @@ -1,23 +1,31 @@ layout_builder.choose_section: - path: '/layout_builder/choose/section/{entity_type_id}/{entity_id}/{delta}' + path: '/layout_builder/choose/section/{entity_type_id}/{entity}/{delta}' defaults: _controller: '\Drupal\layout_builder\Controller\LayoutController::chooseSection' requirements: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.add_section: - path: '/layout_builder/add/section/{entity_type_id}/{entity_id}/{delta}/{plugin_id}' + path: '/layout_builder/add/section/{entity_type_id}/{entity}/{delta}/{plugin_id}' defaults: _controller: '\Drupal\layout_builder\Controller\LayoutController::addSection' requirements: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.configure_section: - path: '/layout_builder/configure/section/{entity_type_id}/{entity_id}/{delta}/{plugin_id}' + path: '/layout_builder/configure/section/{entity_type_id}/{entity}/{delta}/{plugin_id}' defaults: _title: 'Configure section' _form: '\Drupal\layout_builder\Form\ConfigureSectionForm' @@ -26,54 +34,78 @@ layout_builder.configure_section: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.remove_section: - path: '/layout_builder/remove/section/{entity_type_id}/{entity_id}/{delta}' + path: '/layout_builder/remove/section/{entity_type_id}/{entity}/{delta}' defaults: _form: '\Drupal\layout_builder\Form\RemoveSectionForm' requirements: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.choose_block: - path: '/layout_builder/choose/block/{entity_type_id}/{entity_id}/{delta}/{region}' + path: '/layout_builder/choose/block/{entity_type_id}/{entity}/{delta}/{region}' defaults: _controller: '\Drupal\layout_builder\Controller\LayoutController::chooseBlock' requirements: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.add_block: - path: '/layout_builder/add/block/{entity_type_id}/{entity_id}/{delta}/{region}/{plugin_id}' + path: '/layout_builder/add/block/{entity_type_id}/{entity}/{delta}/{region}/{plugin_id}' defaults: _form: '\Drupal\layout_builder\Form\ConfigureBlockForm' requirements: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.configure_block: - path: '/layout_builder/configure/block/{entity_type_id}/{entity_id}/{delta}/{region}/{uuid}' + path: '/layout_builder/configure/block/{entity_type_id}/{entity}/{delta}/{region}/{uuid}' defaults: _form: '\Drupal\layout_builder\Form\ConfigureBlockForm' requirements: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.remove_block: - path: '/layout_builder/remove/block/{entity_type_id}/{entity_id}/{delta}/{region}/{uuid}' + path: '/layout_builder/remove/block/{entity_type_id}/{entity}/{delta}/{region}/{uuid}' defaults: _form: '\Drupal\layout_builder\Form\RemoveBlockForm' requirements: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE layout_builder.move_block: - path: '/layout_builder/move/block/{entity_type_id}/{entity_id}' + path: '/layout_builder/move/block/{entity_type_id}/{entity}' defaults: _controller: '\Drupal\layout_builder\Controller\LayoutController::moveBlock' methods: [POST] @@ -81,6 +113,10 @@ layout_builder.move_block: _permission: 'configure any layout' options: _admin_route: TRUE + parameters: + entity: + type: entity:{entity_type_id} + layout_builder_tempstore: TRUE route_callbacks: - 'layout_builder.routes:getRoutes' diff --git a/core/modules/layout_builder/layout_builder.services.yml b/core/modules/layout_builder/layout_builder.services.yml index defcfca..ba8e0cc 100644 --- a/core/modules/layout_builder/layout_builder.services.yml +++ b/core/modules/layout_builder/layout_builder.services.yml @@ -20,3 +20,8 @@ services: arguments: ['@entity_type.manager'] tags: - { name: route_enhancer } + layout_builder.param_converter: + class: Drupal\layout_builder\Routing\LayoutTempstoreParamConverter + arguments: ['@entity.manager', '@layout_builder.tempstore_repository'] + tags: + - { name: paramconverter, priority: 10 } diff --git a/core/modules/layout_builder/src/Access/LayoutSectionAccessCheck.php b/core/modules/layout_builder/src/Access/LayoutSectionAccessCheck.php index e08dd12..8525eea 100644 --- a/core/modules/layout_builder/src/Access/LayoutSectionAccessCheck.php +++ b/core/modules/layout_builder/src/Access/LayoutSectionAccessCheck.php @@ -43,7 +43,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager) { * The access result. */ public function access(RouteMatchInterface $route_match, AccountInterface $account) { - $entity = $route_match->getParameter('layout_section_entity'); + $entity = $route_match->getParameter('entity'); // If we don't have an entity, forbid access. if (empty($entity)) { return AccessResult::forbidden()->addCacheContexts(['route']); diff --git a/core/modules/layout_builder/src/Controller/LayoutBuilderController.php b/core/modules/layout_builder/src/Controller/LayoutBuilderController.php index c0e361d..a7d13f5 100644 --- a/core/modules/layout_builder/src/Controller/LayoutBuilderController.php +++ b/core/modules/layout_builder/src/Controller/LayoutBuilderController.php @@ -4,14 +4,14 @@ use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\FieldableEntityInterface; -use Drupal\Core\Entity\RevisionableInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Layout\LayoutPluginManagerInterface; use Drupal\Core\Link; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Url; use Drupal\layout_builder\LayoutSectionBuilder; +use Drupal\layout_builder\LayoutSectionItemInterface; use Drupal\layout_builder\LayoutTempstoreRepositoryInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -86,44 +86,39 @@ public static function create(ContainerInterface $container) { /** * Provides a title callback. * - * @param \Drupal\Core\Entity\FieldableEntityInterface $layout_section_entity + * @param \Drupal\Core\Entity\EntityInterface $entity * The entity. * * @return string * The title for the layout page. */ - public function title(FieldableEntityInterface $layout_section_entity) { - return $this->t('Edit layout for %label', ['%label' => $layout_section_entity->label()]); + public function title(EntityInterface $entity) { + return $this->t('Edit layout for %label', ['%label' => $entity->label()]); } /** * Renders the Layout UI. * - * @param \Drupal\Core\Entity\FieldableEntityInterface $layout_section_entity + * @param \Drupal\Core\Entity\EntityInterface $entity * The entity. * * @return array * A render array. */ - public function layout(FieldableEntityInterface $layout_section_entity) { - $layout_section_entity = $this->layoutTempstoreRepository->get($layout_section_entity); - $entity_id = $layout_section_entity->id(); - if ($layout_section_entity instanceof RevisionableInterface) { - $entity_id = $layout_section_entity->getRevisionId(); - } + public function layout(EntityInterface $entity) { + $entity_id = $entity->id(); - $entity_type_id = $layout_section_entity->getEntityTypeId(); + $entity_type_id = $entity->getEntityTypeId(); $output = []; $count = 0; - $output[] = $this->buildAddSectionLink($entity_type_id, $entity_id, $count); - $count++; /** @var \Drupal\layout_builder\LayoutSectionItemInterface $item */ - foreach ($layout_section_entity->layout_builder__layout as $item) { - $output[] = $this->buildAdministrativeSection($item->layout, $item->layout_settings ?: [], $item->section ?: [], $entity_type_id, $entity_id, $count - 1); + foreach ($entity->layout_builder__layout as $item) { $output[] = $this->buildAddSectionLink($entity_type_id, $entity_id, $count); + $output[] = $this->buildAdministrativeSection($item, $entity, $count); $count++; } + $output[] = $this->buildAddSectionLink($entity_type_id, $entity_id, $count); $output['#attached']['library'][] = 'layout_builder/drupal.layout_builder'; $output['#type'] = 'container'; $output['#attributes']['id'] = 'layout-builder'; @@ -150,7 +145,7 @@ protected function buildAddSectionLink($entity_type_id, $entity_id, $delta) { 'layout_builder.choose_section', [ 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity' => $entity_id, 'delta' => $delta, ], [ @@ -173,31 +168,32 @@ protected function buildAddSectionLink($entity_type_id, $entity_id, $delta) { /** * Builds the render array for the layout section while editing. * - * @param string $layout_id - * The ID of the layout. - * @param array $layout_settings - * The configuration for the layout. - * @param array $section - * An array of configuration, keyed first by region and then by block UUID. - * @param string $entity_type_id - * The entity type. - * @param string $entity_id - * The entity ID. + * @param \Drupal\layout_builder\LayoutSectionItemInterface $item + * The layout section item. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity. * @param int $delta - * The delta of the section to splice. + * The delta of the section. * * @return array * The render array for a given section. */ - protected function buildAdministrativeSection($layout_id, array $layout_settings, array $section, $entity_type_id, $entity_id, $delta) { + protected function buildAdministrativeSection(LayoutSectionItemInterface $item, EntityInterface $entity, $delta) { + $layout_id = $item->layout; + $layout_settings = $item->layout_settings; + $section = $item->section; + $entity_type_id = $entity->getEntityTypeId(); + $entity_id = $entity->id(); + $build = $this->builder->buildSection($layout_id, $layout_settings, $section); + $layout_definition = $this->layoutManager->getDefinition($layout_id); foreach ($layout_definition->getRegions() as $region => $info) { $link = Link::createFromRoute($this->t('Add Block'), 'layout_builder.choose_block', [ 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity' => $entity_id, 'delta' => $delta, 'region' => $region, ], @@ -224,7 +220,7 @@ protected function buildAdministrativeSection($layout_id, array $layout_settings 'layout_builder_block' => [ 'route_parameters' => [ 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity' => $entity_id, 'delta' => $delta, 'region' => $region, 'uuid' => $uuid, @@ -237,7 +233,7 @@ protected function buildAdministrativeSection($layout_id, array $layout_settings $build['#attributes']['data-layout-update-url'] = Url::fromRoute('layout_builder.move_block', [ 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity' => $entity_id, ])->toString(); $build['#attributes']['data-layout-delta'] = $delta; $build['#attributes']['class'][] = 'layout-builder--layout'; @@ -254,7 +250,7 @@ protected function buildAdministrativeSection($layout_id, array $layout_settings '#access' => $layout instanceof PluginFormInterface, '#url' => Url::fromRoute('layout_builder.configure_section', [ 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity' => $entity_id, 'delta' => $delta, ]), '#attributes' => [ @@ -268,7 +264,7 @@ protected function buildAdministrativeSection($layout_id, array $layout_settings '#title' => $this->t('Remove section'), '#url' => Url::fromRoute('layout_builder.remove_section', [ 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity' => $entity_id, 'delta' => $delta, ]), '#attributes' => [ @@ -284,37 +280,35 @@ protected function buildAdministrativeSection($layout_id, array $layout_settings /** * Saves the layout. * - * @param \Drupal\Core\Entity\FieldableEntityInterface $layout_section_entity + * @param \Drupal\Core\Entity\EntityInterface $entity * The entity. * * @return \Symfony\Component\HttpFoundation\RedirectResponse * A redirect response. */ - public function saveLayout(FieldableEntityInterface $layout_section_entity) { - $layout_section_entity = $this->layoutTempstoreRepository->get($layout_section_entity); - + public function saveLayout(EntityInterface $entity) { // @todo figure out if we should save a new revision. - $layout_section_entity->save(); + $entity->save(); - $this->layoutTempstoreRepository->delete($layout_section_entity); + $this->layoutTempstoreRepository->delete($entity); // @todo Make trusted redirect instead. - return new RedirectResponse($layout_section_entity->toUrl()->setAbsolute()->toString(), Response::HTTP_SEE_OTHER); + return new RedirectResponse($entity->toUrl()->setAbsolute()->toString(), Response::HTTP_SEE_OTHER); } /** * Cancels the layout. * - * @param \Drupal\Core\Entity\FieldableEntityInterface $layout_section_entity + * @param \Drupal\Core\Entity\EntityInterface $entity * The entity. * * @return \Symfony\Component\HttpFoundation\RedirectResponse * A redirect response. */ - public function cancelLayout(FieldableEntityInterface $layout_section_entity) { - $this->layoutTempstoreRepository->delete($layout_section_entity); + public function cancelLayout(EntityInterface $entity) { + $this->layoutTempstoreRepository->delete($entity); // @todo Make trusted redirect instead. - return new RedirectResponse($layout_section_entity->toUrl()->setAbsolute()->toString(), Response::HTTP_SEE_OTHER); + return new RedirectResponse($entity->toUrl()->setAbsolute()->toString(), Response::HTTP_SEE_OTHER); } } diff --git a/core/modules/layout_builder/src/Controller/LayoutController.php b/core/modules/layout_builder/src/Controller/LayoutController.php index 8524a13..416f95e 100644 --- a/core/modules/layout_builder/src/Controller/LayoutController.php +++ b/core/modules/layout_builder/src/Controller/LayoutController.php @@ -5,6 +5,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Layout\LayoutPluginManagerInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -72,17 +73,15 @@ public static function create(ContainerInterface $container) { /** * Choose a layout plugin to add as a section. * - * @param string $entity_type_id - * The entity type ID. - * @param string $entity_id - * The entity ID. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity. * @param int $delta * The delta of the section to splice. * * @return array * The render array. */ - public function chooseSection($entity_type_id, $entity_id, $delta) { + public function chooseSection(EntityInterface $entity, $delta) { $output = []; $items = []; foreach ($this->layoutManager->getDefinitions() as $plugin_id => $definition) { @@ -105,7 +104,7 @@ public function chooseSection($entity_type_id, $entity_id, $delta) { '#children' => $definition->getLabel(), ], ], - '#url' => $this->generateSectionUrl($entity_type_id, $entity_id, $delta, $plugin_id), + '#url' => $this->generateSectionUrl($entity, $delta, $plugin_id), '#attributes' => [ 'class' => ['use-ajax'], 'data-dialog-type' => 'dialog', @@ -140,10 +139,8 @@ public function chooseSection($entity_type_id, $entity_id, $delta) { /** * Add the layout to the entity field in a tempstore. * - * @param string $entity_type_id - * The entity type ID. - * @param string $entity_id - * The entity ID. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity. * @param int $delta * The delta of the section to splice. * @param string $plugin_id @@ -152,8 +149,7 @@ public function chooseSection($entity_type_id, $entity_id, $delta) { * @return \Drupal\Core\Ajax\AjaxResponse * The render array. */ - public function addSection($entity_type_id, $entity_id, $delta, $plugin_id) { - $entity = $this->layoutTempstoreRepository->getFromId($entity_type_id, $entity_id); + public function addSection(EntityInterface $entity, $delta, $plugin_id) { /** @var \Drupal\layout_builder\Field\LayoutSectionItemListInterface $field_list */ $field_list = $entity->layout_builder__layout; @@ -170,10 +166,8 @@ public function addSection($entity_type_id, $entity_id, $delta, $plugin_id) { /** * Provides the UI for choosing a new block. * - * @param string $entity_type_id - * The entity type ID. - * @param string $entity_id - * The entity ID. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity. * @param int $delta * The delta of the section to splice. * @param string $region @@ -182,7 +176,7 @@ public function addSection($entity_type_id, $entity_id, $delta, $plugin_id) { * @return array * A render array. */ - public function chooseBlock($entity_type_id, $entity_id, $delta, $region) { + public function chooseBlock(EntityInterface $entity, $delta, $region) { $build['#type'] = 'container'; $build['#attributes']['class'][] = 'block-categories'; @@ -199,8 +193,8 @@ public function chooseBlock($entity_type_id, $entity_id, $delta, $region) { '#title' => $block['admin_label'], '#url' => Url::fromRoute('layout_builder.add_block', [ - 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity_type_id' => $entity->getEntityTypeId(), + 'entity' => $entity->id(), 'delta' => $delta, 'region' => $region, 'plugin_id' => $block_id, @@ -220,18 +214,15 @@ public function chooseBlock($entity_type_id, $entity_id, $delta, $region) { /** * Moves a block to another region. * + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity. * @param \Symfony\Component\HttpFoundation\Request $request * The request. - * @param string $entity_type_id - * The entity type ID. - * @param string $entity_id - * The entity ID. * * @return \Drupal\Core\Ajax\AjaxResponse * An AJAX response. */ - public function moveBlock(Request $request, $entity_type_id, $entity_id) { - $entity = $this->layoutTempstoreRepository->getFromId($entity_type_id, $entity_id); + public function moveBlock(EntityInterface $entity, Request $request) { $data = $request->request->all(); /** @var \Drupal\layout_builder\LayoutSectionItemInterface $field */ @@ -269,10 +260,8 @@ public function moveBlock(Request $request, $entity_type_id, $entity_id) { /** * A helper function for building Url object to add a section. * - * @param string $entity_type_id - * The entity type. - * @param string $entity_id - * The entity ID. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity. * @param int $delta * The delta of the section to splice. * @param string $plugin_id @@ -281,12 +270,12 @@ public function moveBlock(Request $request, $entity_type_id, $entity_id) { * @return \Drupal\Core\Url * The Url object of the add_section route. */ - protected function generateSectionUrl($entity_type_id, $entity_id, $delta, $plugin_id) { + protected function generateSectionUrl(EntityInterface $entity, $delta, $plugin_id) { $layout = $this->layoutManager->createInstance($plugin_id); $route_name = $layout instanceof PluginFormInterface ? 'layout_builder.configure_section' : 'layout_builder.add_section'; return new Url($route_name, [ - 'entity_type_id' => $entity_type_id, - 'entity_id' => $entity_id, + 'entity_type_id' => $entity->getEntityTypeId(), + 'entity' => $entity->id(), 'delta' => $delta, 'plugin_id' => $plugin_id, ]); diff --git a/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php b/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php index 77e2e67..acd45d0 100644 --- a/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php +++ b/core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php @@ -38,26 +38,12 @@ public function ajaxSubmit(array &$form, FormStateInterface $form_state) { $response->addCommand(new ReplaceCommand('[data-drupal-selector="' . $form['#attributes']['data-drupal-selector'] . '"]', $form)); } else { - $entity = $this->getLayoutTempstoreRepository()->getFromId($this->entityTypeId, $this->entityId); - $response = $this->rebuildAndClose(new AjaxResponse(), $entity); + $response = $this->rebuildAndClose(new AjaxResponse(), $this->entity); } return $response; } /** - * Gets the layout tempstore repository. - * - * @return \Drupal\layout_builder\LayoutTempstoreRepositoryInterface - * The layout tempstore repository. - */ - protected function getLayoutTempstoreRepository() { - if (!$this->layoutTempstoreRepository) { - $this->layoutTempstoreRepository = \Drupal::service('layout_builder.tempstore_repository'); - } - return $this->layoutTempstoreRepository; - } - - /** * Rebuilds the layout. * * @param \Drupal\Core\Ajax\AjaxResponse $response diff --git a/core/modules/layout_builder/src/Form/ConfigureBlockForm.php b/core/modules/layout_builder/src/Form/ConfigureBlockForm.php index 05fe415..c004a32 100644 --- a/core/modules/layout_builder/src/Form/ConfigureBlockForm.php +++ b/core/modules/layout_builder/src/Form/ConfigureBlockForm.php @@ -6,7 +6,7 @@ use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\DependencyInjection\ClassResolverInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\SubformState; @@ -49,13 +49,6 @@ class ConfigureBlockForm extends FormBase { protected $layoutTempstoreRepository; /** - * The entity type manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - - /** * The block manager. * * @var \Drupal\Core\Block\BlockManagerInterface @@ -84,20 +77,6 @@ class ConfigureBlockForm extends FormBase { protected $pluginFormFactory; /** - * The entity type ID. - * - * @var string - */ - protected $entityTypeId; - - /** - * The entity ID. - * - * @var int - */ - protected $entityId; - - /** * The field delta. * * @var int @@ -112,14 +91,19 @@ class ConfigureBlockForm extends FormBase { protected $region; /** + * The entity. + * + * @var \Drupal\Core\Entity\EntityInterface + */ + protected $entity; + + /** * Constructs a new ConfigureBlockForm. * * @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\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. * @param \Drupal\Core\Block\BlockManagerInterface $block_manager * The block manager. * @param \Drupal\Component\Uuid\UuidInterface $uuid @@ -129,10 +113,9 @@ class ConfigureBlockForm extends FormBase { * @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_manager * The plugin form manager. */ - public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, ContextRepositoryInterface $context_repository, EntityTypeManagerInterface $entity_type_manager, BlockManagerInterface $block_manager, UuidInterface $uuid, ClassResolverInterface $class_resolver, PluginFormFactoryInterface $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) { $this->layoutTempstoreRepository = $layout_tempstore_repository; $this->contextRepository = $context_repository; - $this->entityTypeManager = $entity_type_manager; $this->blockManager = $block_manager; $this->uuid = $uuid; $this->classResolver = $class_resolver; @@ -146,7 +129,6 @@ public static function create(ContainerInterface $container) { return new static( $container->get('layout_builder.tempstore_repository'), $container->get('context.repository'), - $container->get('entity_type.manager'), $container->get('plugin.manager.block'), $container->get('uuid'), $container->get('class_resolver'), @@ -183,20 +165,17 @@ protected function prepareBlock($block_id, array $configuration) { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $entity_id = NULL, $delta = NULL, $region = NULL, $plugin_id = NULL, $uuid = NULL) { - $this->entityTypeId = $entity_type_id; - $this->entityId = $entity_id; + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL, $region = NULL, $plugin_id = NULL, $uuid = NULL) { + $this->entity = $entity; $this->delta = $delta; $this->region = $region; $configuration = []; if ($uuid) { - $entity = $this->layoutTempstoreRepository->getFromId($this->entityTypeId, $this->entityId); - /** @var \Drupal\layout_builder\LayoutSectionItemInterface $field */ - $field = $entity->layout_builder__layout->get($this->delta); - $plugin_id = $field->section[$region][$uuid]['id']; - $configuration = $field->section[$region][$uuid]; + $field = $this->entity->layout_builder__layout->get($this->delta); + $plugin_id = $field->section[$region][$uuid]['block']['id']; + $configuration = $field->section[$region][$uuid]['block']; } $this->block = $this->prepareBlock($plugin_id, $configuration); @@ -249,14 +228,13 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $configuration = $this->block->getConfiguration(); /** @var \Drupal\layout_builder\LayoutSectionItemInterface $field */ - $entity = $this->layoutTempstoreRepository->getFromId($this->entityTypeId, $this->entityId); - $field = $entity->layout_builder__layout->get($this->delta); + $field = $this->entity->layout_builder__layout->get($this->delta); $section = $field->section; - $section[$this->region][$configuration['uuid']] = $configuration; + $section[$this->region][$configuration['uuid']]['block'] = $configuration; $field->section = $section; - $this->layoutTempstoreRepository->set($entity); - $form_state->setRedirect("entity.{$this->entityTypeId}.layout", [$this->entityTypeId => $this->entityId]); + $this->layoutTempstoreRepository->set($this->entity); + $form_state->setRedirect("entity.{$this->entity->getEntityTypeId()}.layout", [$this->entity->getEntityTypeId() => $this->entity->id()]); } /** diff --git a/core/modules/layout_builder/src/Form/ConfigureSectionForm.php b/core/modules/layout_builder/src/Form/ConfigureSectionForm.php index 86b9d64..23bf9a7 100644 --- a/core/modules/layout_builder/src/Form/ConfigureSectionForm.php +++ b/core/modules/layout_builder/src/Form/ConfigureSectionForm.php @@ -3,6 +3,7 @@ namespace Drupal\layout_builder\Form; use Drupal\Core\DependencyInjection\ClassResolverInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\SubformState; @@ -10,7 +11,6 @@ use Drupal\layout_builder\Controller\LayoutRebuildTrait; use Drupal\layout_builder\LayoutTempstoreRepositoryInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Provides a form for configuring a layout section. @@ -34,13 +34,6 @@ class ConfigureSectionForm extends FormBase { protected $layout; /** - * The entity type manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - - /** * The class resolver. * * @var \Drupal\Core\DependencyInjection\ClassResolverInterface @@ -55,18 +48,11 @@ class ConfigureSectionForm extends FormBase { protected $layoutManager; /** - * The entity type ID. + * The entity. * - * @var string + * @var \Drupal\Core\Entity\EntityInterface */ - protected $entityTypeId; - - /** - * The entity ID. - * - * @var int - */ - protected $entityId; + protected $entity; /** * The field delta. @@ -89,15 +75,12 @@ class ConfigureSectionForm extends FormBase { * The layout tempstore repository. * @param \Drupal\Core\Layout\LayoutPluginManagerInterface $layout_manager * The layout manager. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver * The class resolver. */ - public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, LayoutPluginManagerInterface $layout_manager, EntityTypeManagerInterface $entity_type_manager, ClassResolverInterface $class_resolver) { + public function __construct(LayoutTempstoreRepositoryInterface $layout_tempstore_repository, LayoutPluginManagerInterface $layout_manager, ClassResolverInterface $class_resolver) { $this->layoutTempstoreRepository = $layout_tempstore_repository; $this->layoutManager = $layout_manager; - $this->entityTypeManager = $entity_type_manager; $this->classResolver = $class_resolver; } @@ -108,7 +91,6 @@ public static function create(ContainerInterface $container) { return new static( $container->get('layout_builder.tempstore_repository'), $container->get('plugin.manager.core.layout'), - $container->get('entity_type.manager'), $container->get('class_resolver') ); } @@ -123,19 +105,15 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $entity_id = NULL, $delta = NULL, $plugin_id = NULL) { - $this->entityTypeId = $entity_type_id; - $this->entityId = $entity_id; + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL, $plugin_id = NULL) { + $this->entity = $entity; $this->delta = $delta; - $this->isUpdate = is_null($plugin_id); $configuration = []; if ($this->isUpdate) { - $entity = $this->layoutTempstoreRepository->getFromId($this->entityTypeId, $this->entityId); - /** @var \Drupal\layout_builder\LayoutSectionItemInterface $field */ - $field = $entity->layout_builder__layout->get($this->delta); + $field = $this->entity->layout_builder__layout->get($this->delta); $plugin_id = $field->layout; $configuration = $field->layout_settings; } @@ -179,10 +157,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $plugin_id = $this->layout->getPluginId(); $configuration = $this->layout->getConfiguration(); - $entity = $this->layoutTempstoreRepository->getFromId($this->entityTypeId, $this->entityId); - /** @var \Drupal\layout_builder\Field\LayoutSectionItemListInterface $field_list */ - $field_list = $entity->layout_builder__layout; + $field_list = $this->entity->layout_builder__layout; if ($this->isUpdate) { $field = $field_list->get($this->delta); $field->layout = $plugin_id; @@ -196,8 +172,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ]); } - $this->layoutTempstoreRepository->set($entity); - $form_state->setRedirect("entity.{$this->entityTypeId}.layout", [$this->entityTypeId => $this->entityId]); + $this->layoutTempstoreRepository->set($this->entity); + $form_state->setRedirect("entity.{$this->entity->getEntityTypeId()}.layout", [$this->entity->getEntityTypeId() => $this->entity->id()]); } } diff --git a/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php b/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php index 82891b9..044f3f3 100644 --- a/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php +++ b/core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php @@ -26,18 +26,11 @@ protected $layoutTempstoreRepository; /** - * The entity type ID. + * The entity. * - * @var string + * @var \Drupal\Core\Entity\EntityInterface */ - protected $entityTypeId; - - /** - * The entity ID. - * - * @var int - */ - protected $entityId; + protected $entity; /** * The field delta. @@ -69,19 +62,18 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function getCancelUrl() { - return Url::fromRoute("entity.{$this->entityTypeId}.layout", [$this->entityTypeId => $this->entityId]); + return Url::fromRoute("entity.{$this->entity->getEntityTypeId()}.layout", [$this->entity->getEntityTypeId() => $this->entity->id()]); } /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $entity_id = NULL, $delta = NULL) { - $form = parent::buildForm($form, $form_state); - - $this->entityTypeId = $entity_type_id; - $this->entityId = $entity_id; + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL) { + $this->entity = $entity; $this->delta = $delta; + $form = parent::buildForm($form, $form_state); + $form['#attached']['library'][] = 'core/drupal.dialog.ajax'; $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit'; @@ -100,11 +92,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $entity = $this->layoutTempstoreRepository->getFromId($this->entityTypeId, $this->entityId); + $this->handleEntity($this->entity, $form_state); - $this->handleEntity($entity, $form_state); - - $this->layoutTempstoreRepository->set($entity); + $this->layoutTempstoreRepository->set($this->entity); $form_state->setRedirectUrl($this->getCancelUrl()); } diff --git a/core/modules/layout_builder/src/Form/RemoveBlockForm.php b/core/modules/layout_builder/src/Form/RemoveBlockForm.php index 99018ed..4254472 100644 --- a/core/modules/layout_builder/src/Form/RemoveBlockForm.php +++ b/core/modules/layout_builder/src/Form/RemoveBlockForm.php @@ -48,10 +48,10 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $entity_id = NULL, $delta = NULL, $region = NULL, $uuid = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL, $region = NULL, $uuid = NULL) { $this->region = $region; $this->uuid = $uuid; - return parent::buildForm($form, $form_state, $entity_type_id, $entity_id, $delta); + return parent::buildForm($form, $form_state, $entity, $delta); } /** diff --git a/core/modules/layout_builder/src/LayoutSectionBuilder.php b/core/modules/layout_builder/src/LayoutSectionBuilder.php index 1b6ce4a..260b528 100644 --- a/core/modules/layout_builder/src/LayoutSectionBuilder.php +++ b/core/modules/layout_builder/src/LayoutSectionBuilder.php @@ -97,7 +97,7 @@ public function buildSection($layout_id, array $layout_settings, array $section) foreach ($section as $region => $blocks) { // @todo determine if config should at least always be an empty array. foreach ($blocks as $uuid => $configuration) { - $block = $this->getBlock($uuid, $configuration); + $block = $this->getBlock($uuid, $configuration['block']); $access = $block->access($this->account, TRUE); $cacheability->addCacheableDependency($access); diff --git a/core/modules/layout_builder/src/LayoutTempstoreRepository.php b/core/modules/layout_builder/src/LayoutTempstoreRepository.php index abd6067..ce778ff 100644 --- a/core/modules/layout_builder/src/LayoutTempstoreRepository.php +++ b/core/modules/layout_builder/src/LayoutTempstoreRepository.php @@ -3,7 +3,6 @@ namespace Drupal\layout_builder; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\RevisionableInterface; use Drupal\user\SharedTempStoreFactory; @@ -20,23 +19,13 @@ class LayoutTempstoreRepository implements LayoutTempstoreRepositoryInterface { protected $tempStoreFactory; /** - * The entity type manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - - /** * LayoutTempstoreRepository constructor. * * @param \Drupal\user\SharedTempStoreFactory $temp_store_factory * The shared tempstore factory. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. */ - public function __construct(SharedTempStoreFactory $temp_store_factory, EntityTypeManagerInterface $entity_type_manager) { + public function __construct(SharedTempStoreFactory $temp_store_factory) { $this->tempStoreFactory = $temp_store_factory; - $this->entityTypeManager = $entity_type_manager; } /** @@ -54,14 +43,6 @@ public function get(EntityInterface $entity) { /** * {@inheritdoc} */ - public function getFromId($entity_type_id, $entity_id) { - $entity = $this->entityTypeManager->getStorage($entity_type_id)->loadRevision($entity_id); - return $this->get($entity); - } - - /** - * {@inheritdoc} - */ public function set(EntityInterface $entity) { list($collection, $id) = $this->generateTempstoreId($entity); $this->tempStoreFactory->get($collection)->set($id, ['entity' => $entity]); diff --git a/core/modules/layout_builder/src/LayoutTempstoreRepositoryInterface.php b/core/modules/layout_builder/src/LayoutTempstoreRepositoryInterface.php index 8043c84..e9fac69 100644 --- a/core/modules/layout_builder/src/LayoutTempstoreRepositoryInterface.php +++ b/core/modules/layout_builder/src/LayoutTempstoreRepositoryInterface.php @@ -22,20 +22,6 @@ public function get(EntityInterface $entity); /** - * Loads an entity from tempstore given the entity ID. - * - * @param string $entity_type_id - * The entity type ID. - * @param string $entity_id - * The entity ID (or revision ID). - * - * @return \Drupal\Core\Entity\EntityInterface - * Either the version of this entity from tempstore, or the entity from - * storage if none exists. - */ - public function getFromId($entity_type_id, $entity_id); - - /** * Stores this entity in tempstore. * * @param \Drupal\Core\Entity\EntityInterface $entity diff --git a/core/modules/layout_builder/src/Plugin/Menu/LayoutBuilderLocalTask.php b/core/modules/layout_builder/src/Plugin/Menu/LayoutBuilderLocalTask.php index 4f80e38..329f5d3 100644 --- a/core/modules/layout_builder/src/Plugin/Menu/LayoutBuilderLocalTask.php +++ b/core/modules/layout_builder/src/Plugin/Menu/LayoutBuilderLocalTask.php @@ -16,7 +16,7 @@ class LayoutBuilderLocalTask extends LocalTaskDefault { public function getRouteParameters(RouteMatchInterface $route_match) { $parameters = parent::getRouteParameters($route_match); - $parameters['layout_section_entity'] = $route_match->getParameter('layout_section_entity'); + $parameters['entity'] = $route_match->getParameter('entity'); return $parameters; } diff --git a/core/modules/layout_builder/src/Routing/LayoutBuilderRouteEnhancer.php b/core/modules/layout_builder/src/Routing/LayoutBuilderRouteEnhancer.php index d19024f..8aee689 100644 --- a/core/modules/layout_builder/src/Routing/LayoutBuilderRouteEnhancer.php +++ b/core/modules/layout_builder/src/Routing/LayoutBuilderRouteEnhancer.php @@ -15,6 +15,7 @@ class LayoutBuilderRouteEnhancer implements RouteEnhancerInterface { * {@inheritdoc} */ public function applies(Route $route) { + // Find layout builder routes that override existing paths. return $route->hasOption('_layout_builder'); } @@ -23,7 +24,7 @@ public function applies(Route $route) { */ public function enhance(array $defaults, Request $request) { // Copy the entity by reference so that any changes are reflected. - $defaults['layout_section_entity'] = &$defaults[$defaults['entity_type_id']]; + $defaults['entity'] = &$defaults[$defaults['entity_type_id']]; return $defaults; } diff --git a/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php b/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php index 7a53f52..97adac6 100644 --- a/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php +++ b/core/modules/layout_builder/src/Routing/LayoutBuilderRoutes.php @@ -46,7 +46,7 @@ public function getRoutes() { ->setDefaults([ '_controller' => '\Drupal\layout_builder\Controller\LayoutBuilderController::layout', '_title_callback' => '\Drupal\layout_builder\Controller\LayoutBuilderController::title', - 'layout_section_entity' => NULL, + 'entity' => NULL, 'entity_type_id' => $entity_type_id, ]) ->addRequirements([ @@ -57,7 +57,8 @@ public function getRoutes() { '_layout_builder' => TRUE, 'parameters' => [ $entity_type_id => [ - 'type' => "entity:$entity_type_id", + 'type' => 'entity:{entity_type_id}', + 'layout_builder_tempstore' => TRUE, ], ], ]); @@ -66,7 +67,7 @@ public function getRoutes() { $route = (new Route("$template/layout/save")) ->setDefaults([ '_controller' => '\Drupal\layout_builder\Controller\LayoutBuilderController::saveLayout', - 'layout_section_entity' => NULL, + 'entity' => NULL, 'entity_type_id' => $entity_type_id, ]) ->addRequirements([ @@ -77,7 +78,8 @@ public function getRoutes() { '_layout_builder' => TRUE, 'parameters' => [ $entity_type_id => [ - 'type' => "entity:$entity_type_id", + 'type' => 'entity:{entity_type_id}', + 'layout_builder_tempstore' => TRUE, ], ], ]); @@ -86,7 +88,7 @@ public function getRoutes() { $route = (new Route("$template/layout/cancel")) ->setDefaults([ '_controller' => '\Drupal\layout_builder\Controller\LayoutBuilderController::cancelLayout', - 'layout_section_entity' => NULL, + 'entity' => NULL, 'entity_type_id' => $entity_type_id, ]) ->addRequirements([ @@ -97,7 +99,8 @@ public function getRoutes() { '_layout_builder' => TRUE, 'parameters' => [ $entity_type_id => [ - 'type' => "entity:$entity_type_id", + 'type' => 'entity:{entity_type_id}', + 'layout_builder_tempstore' => TRUE, ], ], ]); @@ -116,9 +119,13 @@ protected function alterRoutes(RouteCollection $collection) { // Mark this as a Layout Builder route so that links like local tasks // will be enhanced. if ($route = $collection->get('entity.' . $entity_type->id() . '.' . $template)) { + $parameters = $route->getOption('parameters'); + $parameters[$entity_type->id()]['type'] = 'entity:{entity_type_id}'; + $parameters[$entity_type->id()]['layout_builder_tempstore'] = TRUE; + $route->setOption('parameters', $parameters); $route->setOption('_layout_builder', TRUE); $route->addDefaults([ - 'layout_section_entity' => NULL, + 'entity' => NULL, 'entity_type_id' => $entity_type->id(), ]); } diff --git a/core/modules/layout_builder/src/Routing/LayoutTempstoreParamConverter.php b/core/modules/layout_builder/src/Routing/LayoutTempstoreParamConverter.php new file mode 100644 index 0000000..be55f34 --- /dev/null +++ b/core/modules/layout_builder/src/Routing/LayoutTempstoreParamConverter.php @@ -0,0 +1,52 @@ +layoutTempstoreRepository = $layout_tempstore_repository; + } + + /** + * {@inheritdoc} + */ + public function convert($value, $definition, $name, array $defaults) { + if ($entity = parent::convert($value, $definition, $name, $defaults)) { + return $this->layoutTempstoreRepository->get($entity); + } + } + + /** + * {@inheritdoc} + */ + public function applies($definition, $name, Route $route) { + return !empty($definition['layout_builder_tempstore']); + } + +} diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php index 0d63b17..0e30d14 100644 --- a/core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php +++ b/core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php @@ -60,9 +60,11 @@ public function providerTestLayoutSectionFormatter() { 'section' => [ 'content' => [ 'baz' => [ - 'id' => 'test_context_aware', - 'context_mapping' => [ - 'user' => '@user.current_user_context:current_user', + 'block' => [ + 'id' => 'test_context_aware', + 'context_mapping' => [ + 'user' => '@user.current_user_context:current_user', + ], ], ], ], @@ -88,7 +90,9 @@ public function providerTestLayoutSectionFormatter() { 'section' => [ 'content' => [ 'baz' => [ - 'id' => 'system_powered_by_block', + 'block' => [ + 'id' => 'system_powered_by_block', + ], ], ], ], @@ -107,7 +111,9 @@ public function providerTestLayoutSectionFormatter() { 'section' => [ 'content' => [ 'baz' => [ - 'id' => 'system_powered_by_block', + 'block' => [ + 'id' => 'system_powered_by_block', + ], ], ], ], @@ -117,14 +123,18 @@ public function providerTestLayoutSectionFormatter() { 'section' => [ 'first' => [ 'foo' => [ - 'id' => 'test_block_instantiation', - 'display_message' => 'foo text', + 'block' => [ + 'id' => 'test_block_instantiation', + 'display_message' => 'foo text', + ], ], ], 'second' => [ 'bar' => [ - 'id' => 'test_block_instantiation', - 'display_message' => 'bar text', + 'block' => [ + 'id' => 'test_block_instantiation', + 'display_message' => 'bar text', + ], ], ], ], @@ -171,7 +181,9 @@ public function testLayoutSectionFormatterAccess() { 'section' => [ 'content' => [ 'baz' => [ - 'id' => 'test_access', + 'block' => [ + 'id' => 'test_access', + ], ], ], ], @@ -208,7 +220,9 @@ public function testMultilingualLayoutSectionFormatter() { 'section' => [ 'content' => [ 'baz' => [ - 'id' => 'system_powered_by_block', + 'block' => [ + 'id' => 'system_powered_by_block', + ], ], ], ], @@ -222,14 +236,18 @@ public function testMultilingualLayoutSectionFormatter() { 'section' => [ 'first' => [ 'foo' => [ - 'id' => 'test_block_instantiation', - 'display_message' => 'foo text', + 'block' => [ + 'id' => 'test_block_instantiation', + 'display_message' => 'foo text', + ], ], ], 'second' => [ 'bar' => [ - 'id' => 'test_block_instantiation', - 'display_message' => 'bar text', + 'block' => [ + 'id' => 'test_block_instantiation', + 'display_message' => 'bar text', + ], ], ], ], diff --git a/core/modules/layout_builder/tests/src/Unit/LayoutSectionBuilderTest.php b/core/modules/layout_builder/tests/src/Unit/LayoutSectionBuilderTest.php index 468fd50..2b0d10e 100644 --- a/core/modules/layout_builder/tests/src/Unit/LayoutSectionBuilderTest.php +++ b/core/modules/layout_builder/tests/src/Unit/LayoutSectionBuilderTest.php @@ -121,7 +121,9 @@ public function testBuildSection() { $section = [ 'content' => [ 'some_uuid' => [ - 'id' => 'block_plugin_id', + 'block' => [ + 'id' => 'block_plugin_id', + ], ], ], ]; @@ -155,7 +157,9 @@ public function testBuildSectionAccessDenied() { $section = [ 'content' => [ 'some_uuid' => [ - 'id' => 'block_plugin_id', + 'block' => [ + 'id' => 'block_plugin_id', + ], ], ], ]; @@ -225,7 +229,9 @@ public function testContextAwareBlock() { $section = [ 'content' => [ 'some_uuid' => [ - 'id' => 'block_plugin_id', + 'block' => [ + 'id' => 'block_plugin_id', + ], ], ], ]; @@ -250,7 +256,9 @@ public function testContextAwareBlock() { public function testBuildSectionMissingPluginId() { $section = [ 'content' => [ - 'some_uuid' => [], + 'some_uuid' => [ + 'block' => [], + ], ], ]; $this->setExpectedException(PluginException::class, 'No plugin ID specified for block with "some_uuid" UUID');