function hook_entity_duplicate

Acts when duplicating an existing entity.

Parameters

\Drupal\Core\Entity\EntityInterface $duplicate: The duplicated entity object.

\Drupal\Core\Entity\EntityInterface $entity: The original entity object.

See also

hook_ENTITY_TYPE_duplicate()

Related topics

2 invocations of hook_entity_duplicate()
ContentEntityBase::createDuplicate in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Creates a duplicate of the entity.
EntityBase::createDuplicate in core/lib/Drupal/Core/Entity/EntityBase.php
Creates a duplicate of the entity.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 991

Code

function hook_entity_duplicate(\Drupal\Core\Entity\EntityInterface $duplicate, \Drupal\Core\Entity\EntityInterface $entity) : void {
    \Drupal::logger('example')->info('Entity duplicated: @label', [
        '@label' => $entity->label(),
    ]);
}

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