function hook_ENTITY_TYPE_revision_create in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_revision_create()
Respond to entity revision creation.
Parameters
\Drupal\Core\Entity\EntityInterface $new_revision: The new revision that was created.
\Drupal\Core\Entity\EntityInterface $entity: The original entity that was used to create the revision from.
bool|null $keep_untranslatable_fields: Whether untranslatable field values were kept (TRUE) or copied from the default revision (FALSE) when generating a merged revision. If no value was explicitly specified (NULL), a default value of TRUE should be assumed if the provided entity is the default translation and untranslatable fields should only affect the default translation, FALSE otherwise.
See also
\Drupal\Core\Entity\RevisionableStorageInterface::createRevision()
\Drupal\Core\Entity\TranslatableRevisionableStorageInterface::createRevision()
Related topics
2 functions implement hook_ENTITY_TYPE_revision_create()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- entity_test_entity_revision_create in core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module - Implements hook_entity_revision_create().
- entity_test_entity_test_mulrev_revision_create in core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module - Implements hook_ENTITY_TYPE_revision_create() for 'entity_test_mulrev'.
File
- core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 983 - Hooks and documentation related to entities.
Code
function hook_ENTITY_TYPE_revision_create(\Drupal\Core\Entity\EntityInterface $new_revision, \Drupal\Core\Entity\EntityInterface $entity, $keep_untranslatable_fields) {
// Retain the value from an untranslatable field, which are by default
// synchronized from the default revision.
$new_revision
->set('untranslatable_field', $entity
->get('untranslatable_field'));
}