Commit 78816375 authored by xjm's avatar xjm

Issue #3007973 by tim.plunkett, lukasss, xopoc, bnjmnm, stompersly: Layout...

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 fea6c512)
parent 7041c1c5
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\field\FieldConfigInterface; use Drupal\field\FieldConfigInterface;
...@@ -14,7 +15,6 @@ ...@@ -14,7 +15,6 @@
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage; use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage;
use Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm; use Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface;
use Drupal\layout_builder\Plugin\Block\ExtraFieldBlock; use Drupal\layout_builder\Plugin\Block\ExtraFieldBlock;
use Drupal\layout_builder\InlineBlockEntityOperations; use Drupal\layout_builder\InlineBlockEntityOperations;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
...@@ -106,7 +106,9 @@ function layout_builder_field_config_delete(FieldConfigInterface $field_config) ...@@ -106,7 +106,9 @@ function layout_builder_field_config_delete(FieldConfigInterface $field_config)
* @see layout_builder_module_implements_alter() * @see layout_builder_module_implements_alter()
*/ */
function layout_builder_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) { 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 */ /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $field_manager */
$field_manager = \Drupal::service('entity_field.manager'); $field_manager = \Drupal::service('entity_field.manager');
$extra_fields = $field_manager->getExtraFields($entity->getEntityTypeId(), $entity->bundle()); $extra_fields = $field_manager->getExtraFields($entity->getEntityTypeId(), $entity->bundle());
......
...@@ -482,6 +482,23 @@ public function testLayoutBuilderChooseBlocksAlter() { ...@@ -482,6 +482,23 @@ public function testLayoutBuilderChooseBlocksAlter() {
$assert_session->linkExists('Changed'); $assert_session->linkExists('Changed');
} }
/**
* 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. * Tests that deleting a View block used in Layout Builder works.
*/ */
......
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