function EntityTestHooks::entityDuplicateAlter

Implements hook_entity_duplicate().

File

core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php, line 713

Class

EntityTestHooks
Hook implementations for entity_test.

Namespace

Drupal\entity_test\Hook

Code

public function entityDuplicateAlter(EntityInterface $duplicate, EntityInterface $entity) : void {
    if ($duplicate instanceof ContentEntityInterface && str_contains($duplicate->label(), 'UUID CRUD test entity') && $duplicate->hasField('name')) {
        $duplicate->set('name', $duplicate->label() . ' duplicate');
    }
}

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