Skip to content
Snippets Groups Projects

Resolve #3506267 "Changing page title"

Files
2
@@ -36,13 +36,19 @@ class AutoSaveManager {
'data' => $data,
'data_hash' => \hash('xxh64', \serialize($data)),
'langcode' => $entity instanceof TranslatableInterface ? $entity->language()->getId() : NULL,
// @todo Update label from incoming entity data once it exists.
'label' => (string) $entity->label(),
'label' => self::getLabelToSave($entity, $data),
];
$this->getTempStore()->set($key, $auto_save_data);
$this->cacheTagsInvalidator->invalidateTags([self::CACHE_TAG]);
}
public static function getLabelToSave(EntityInterface $entity, array $data): string {
$key = \sprintf("%s[0][value]", $entity->getEntityType()->getKey('label'));
return empty($data['entity_form_fields'][$key]) ?
(string) $entity->label() :
(string) $data['entity_form_fields'][$key];
}
public static function getAutoSaveKey(EntityInterface $entity): string {
// @todo Make use of https://www.drupal.org/project/drupal/issues/3026957
// @todo This will likely to also take into account the workspace ID.
Loading