Verified Commit 6ffbfe25 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3126746 by danflanagan8, Deepak Goyal, Neslee Canil Pinto, geek-merlin,...

Issue #3126746 by danflanagan8, Deepak Goyal, Neslee Canil Pinto, geek-merlin, tim.plunkett: LayoutBuilderHtmlEntityFormController breaks decoration
parent b55eafe3
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
/**
 * Overrides the entity form controller service for layout builder operations.
 */
class LayoutBuilderHtmlEntityFormController {
class LayoutBuilderHtmlEntityFormController extends FormController {

  use DependencySerializationTrait;

@@ -56,4 +56,18 @@ public function getContentResult(Request $request, RouteMatchInterface $route_ma
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  protected function getFormArgument(RouteMatchInterface $route_match) {
    return $this->entityFormController->getFormArgument($route_match);
  }

  /**
   * {@inheritdoc}
   */
  protected function getFormObject(RouteMatchInterface $route_match, $form_arg) {
    return $this->entityFormController->getFormObject($route_match, $form_arg);
  }

}
+5 −0
Original line number Diff line number Diff line
name: 'Layout Builder Decoration test'
type: module
description: 'Support module for testing layout building.'
package: Testing
version: VERSION
+6 −0
Original line number Diff line number Diff line
services:
  layout_builder_decoration_test.controller.entity_form:
    decorates: controller.entity_form
    class: Drupal\layout_builder_decoration_test\Controller\LayoutBuilderDecorationTestHtmlEntityFormController
    public: false
    arguments: ['@layout_builder_decoration_test.controller.entity_form.inner']
+52 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\layout_builder_decoration_test\Controller;

use Drupal\Core\Controller\FormController;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Overrides the entity form controller service for layout builder decoration test.
 */
class LayoutBuilderDecorationTestHtmlEntityFormController extends FormController {

  /**
   * The entity form controller being decorated.
   *
   * @var \Drupal\Core\Controller\FormController
   */
  protected $entityFormController;

  /**
   * Constructs a LayoutBuilderDecorationTestHtmlEntityFormController object.
   *
   * @param \Drupal\Core\Controller\FormController $entity_form_controller
   *   The entity form controller being decorated.
   */
  public function __construct(FormController $entity_form_controller) {
    $this->entityFormController = $entity_form_controller;
  }

  /**
   * {@inheritdoc}
   */
  public function getContentResult(Request $request, RouteMatchInterface $route_match) {
    return $this->entityFormController->getContentResult($request, $route_match);
  }

  /**
   * {@inheritdoc}
   */
  protected function getFormArgument(RouteMatchInterface $route_match) {
    return $this->entityFormController->getFormArgument($route_match);
  }

  /**
   * {@inheritdoc}
   */
  protected function getFormObject(RouteMatchInterface $route_match, $form_arg) {
    return $this->entityFormController->getFormObject($route_match, $form_arg);
  }

}
+17 −0
Original line number Diff line number Diff line
@@ -447,6 +447,23 @@ public function testLayoutBuilderUi() {
    $this->assertSame($expected_labels, $labels);
  }

  /**
   * Test decorating controller.entity_form while layout_builder is installed.
   */
  public function testHtmlEntityFormControllerDecoration() {
    $assert_session = $this->assertSession();

    $this->drupalLogin($this->drupalCreateUser([
      'configure any layout',
      'administer node display',
    ]));

    // Install module that decorates controller.entity_form.
    \Drupal::service('module_installer')->install(['layout_builder_decoration_test']);
    $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
    $assert_session->pageTextContains('Manage Display');
  }

  /**
   * Test that layout builder checks entity view access.
   */