function LayoutBuilderHooks::entityUpdate
Implements hook_entity_update().
Attributes
#[Hook('entity_update')]
File
-
core/
modules/ layout_builder/ src/ Hook/ LayoutBuilderHooks.php, line 226
Class
- LayoutBuilderHooks
- Hook implementations for layout_builder.
Namespace
Drupal\layout_builder\HookCode
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.