function hook_ENTITY_TYPE_revision_create

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_revision_create()
  2. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_revision_create()
  3. 10 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

1 function implements 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_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 1019

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'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.