Skip to content
Snippets Groups Projects

#3035992 Stale values can be displayed by the Layout Builder UI but are saved correctly

Open #3035992 Stale values can be displayed by the Layout Builder UI but are saved correctly
Open Roman Paska requested to merge issue/drupal-3035992:3035992-stale-values-can into 11.x
Compare and
5 files
+ 242
20
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -23,6 +23,7 @@
use Drupal\layout_builder\Form\DefaultsEntityForm;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
use Drupal\layout_builder\LayoutOverrideFieldHelper;
use Drupal\Core\Url;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Hook\Attribute\Hook;
@@ -219,6 +220,26 @@ public function entityDelete(EntityInterface $entity): void {
}
}
/**
* Implements hook_entity_update().
*/
#[Hook('entity_update')]
public function entityUpdate(EntityInterface $entity): void {
// See if the entity's layout must be updated with the new entity values if:
// 1. It is a fieldable layout
// 2. A layout override field is present.
// @todo Remove instanceof FieldableEntityInterface check in
// https://www.drupal.org/node/3046216
if ($entity instanceof FieldableEntityInterface && $entity->hasField(OverridesSectionStorage::FIELD_NAME)) {
// If an entity's field values change, and it also has a layout override
// in the tempstore, the tempstore must be updated to reflect those new
// values.
/** @var \Drupal\layout_builder\LayoutOverrideFieldHelper $override_field_helper */
$override_field_helper = \Drupal::classResolver(LayoutOverrideFieldHelper::class);
$override_field_helper->updateTempstoreEntityContext($entity);
}
}
/**
* Implements hook_cron().
*/
Loading