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
Related topics
1 function implements hook_entity_duplicate()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- EntityTestHooks::entityDuplicateAlter in core/
modules/ system/ tests/ modules/ entity_test/ src/ Hook/ EntityTestHooks.php - Implements hook_entity_duplicate().
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.