|
7 | 7 |
|
8 | 8 | use Drupal\Core\Entity\EntityInterface; |
9 | 9 | use Drupal\Core\Form\FormStateInterface; |
| 10 | +use Drupal\Core\Render\Element; |
10 | 11 | use Drupal\Core\Routing\RouteMatchInterface; |
11 | 12 | use Drupal\Core\Url; |
12 | 13 | use Drupal\field\FieldConfigInterface; |
13 | 14 | use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; |
14 | 15 | use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage; |
15 | 16 | use Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm; |
16 | 17 | use Drupal\Core\Entity\Display\EntityViewDisplayInterface; |
17 | | -use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface; |
18 | 18 | use Drupal\layout_builder\Plugin\Block\ExtraFieldBlock; |
19 | 19 | use Drupal\layout_builder\InlineBlockEntityOperations; |
20 | 20 | use Drupal\Core\Session\AccountInterface; |
@@ -106,7 +106,9 @@ function layout_builder_field_config_delete(FieldConfigInterface $field_config) |
106 | 106 | * @see layout_builder_module_implements_alter() |
107 | 107 | */ |
108 | 108 | function layout_builder_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) { |
109 | | - if ($display instanceof LayoutEntityDisplayInterface) { |
| 109 | + // Only replace extra fields when Layout Builder has been used to alter the |
| 110 | + // build. See \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay::buildMultiple(). |
| 111 | + if (isset($build['_layout_builder']) && !Element::isEmpty($build['_layout_builder'])) { |
110 | 112 | /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $field_manager */ |
111 | 113 | $field_manager = \Drupal::service('entity_field.manager'); |
112 | 114 | $extra_fields = $field_manager->getExtraFields($entity->getEntityTypeId(), $entity->bundle()); |
|
0 commit comments