summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorxjm2019-01-09 21:24:56 (GMT)
committerxjm2019-01-09 21:25:36 (GMT)
commit7881637548a18fdc0b31e5eb3aa3cf479c44ebf4 (patch)
treea8c4061835652a01289d2a33dcf524a99523bf58 /core
parent7041c1c520ff5f94f88048353165983efa8cb9a7 (diff)
Issue #3007973 by tim.plunkett, lukasss, xopoc, bnjmnm, stompersly: Layout builder prevents the rendering of extra fields (like Links) on pages not using Layout Builder
(cherry picked from commit fea6c512263d890eabeeccf1f29872f90250f6ff)
Diffstat (limited to 'core')
-rw-r--r--core/modules/layout_builder/layout_builder.module6
-rw-r--r--core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php17
2 files changed, 21 insertions, 2 deletions
diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module
index 373f7d8..aeb9635 100644
--- a/core/modules/layout_builder/layout_builder.module
+++ b/core/modules/layout_builder/layout_builder.module
@@ -7,6 +7,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\field\FieldConfigInterface;
@@ -14,7 +15,6 @@ use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage;
use Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
-use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface;
use Drupal\layout_builder\Plugin\Block\ExtraFieldBlock;
use Drupal\layout_builder\InlineBlockEntityOperations;
use Drupal\Core\Session\AccountInterface;
@@ -106,7 +106,9 @@ function layout_builder_field_config_delete(FieldConfigInterface $field_config)
* @see layout_builder_module_implements_alter()
*/
function layout_builder_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
- if ($display instanceof LayoutEntityDisplayInterface) {
+ // Only replace extra fields when Layout Builder has been used to alter the
+ // build. See \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::buildMultiple().
+ if (isset($build['_layout_builder']) && !Element::isEmpty($build['_layout_builder'])) {
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $field_manager */
$field_manager = \Drupal::service('entity_field.manager');
$extra_fields = $field_manager->getExtraFields($entity->getEntityTypeId(), $entity->bundle());
diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php
index be04c32..eb7f5a2 100644
--- a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php
+++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php
@@ -483,6 +483,23 @@ class LayoutBuilderTest extends BrowserTestBase {
}
/**
+ * Tests that extra fields work before and after enabling Layout Builder.
+ */
+ public function testExtraFields() {
+ $assert_session = $this->assertSession();
+
+ $this->drupalLogin($this->drupalCreateUser(['administer node display']));
+
+ $this->drupalGet('node');
+ $assert_session->linkExists('Read more');
+
+ $this->drupalPostForm('admin/structure/types/manage/bundle_with_section_field/display/default', ['layout[enabled]' => TRUE], 'Save');
+
+ $this->drupalGet('node');
+ $assert_session->linkExists('Read more');
+ }
+
+ /**
* Tests that deleting a View block used in Layout Builder works.
*/
public function testDeletedView() {