Unverified Commit bd3795dc authored by larowlan's avatar larowlan

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

(cherry picked from commit 6ffbfe25)
parent 69345ad8
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
/** /**
* Overrides the entity form controller service for layout builder operations. * Overrides the entity form controller service for layout builder operations.
*/ */
class LayoutBuilderHtmlEntityFormController { class LayoutBuilderHtmlEntityFormController extends FormController {
use DependencySerializationTrait; use DependencySerializationTrait;
...@@ -56,4 +56,18 @@ public function getContentResult(Request $request, RouteMatchInterface $route_ma ...@@ -56,4 +56,18 @@ public function getContentResult(Request $request, RouteMatchInterface $route_ma
return $form; 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);
}
} }
name: 'Layout Builder Decoration test'
type: module
description: 'Support module for testing layout building.'
package: Testing
version: VERSION
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']
<?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);
}
}
...@@ -447,6 +447,23 @@ public function testLayoutBuilderUi() { ...@@ -447,6 +447,23 @@ public function testLayoutBuilderUi() {
$this->assertSame($expected_labels, $labels); $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. * Test that layout builder checks entity view access.
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment