function hook_entity_revision_create
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_revision_create()
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_revision_create()
- 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_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
1 function implements hook_entity_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().
1 invocation of hook_entity_revision_create()
- ContentEntityStorageBase::createRevision in core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php - Creates a new revision starting off from the specified entity object.
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 995
Code
function hook_entity_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'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.