protected function EntityDuplicateFormTrait::postSave in Entity API 8
Invokes entity duplicate hooks after the entity has been duplicated.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The saved entity.
string $operation: The form operation.
1 call to EntityDuplicateFormTrait::postSave()
- EnhancedEntityForm::save in tests/
modules/ entity_module_test/ src/ Form/ EnhancedEntityForm.php - Form submission handler for the 'save' action.
File
- src/
Form/ EntityDuplicateFormTrait.php, line 47
Class
- EntityDuplicateFormTrait
- Allows forms to implement EntityDuplicateFormInterface.
Namespace
Drupal\entity\FormCode
protected function postSave(EntityInterface $entity, $operation) {
if ($operation == 'duplicate') {
// An event is used instead of a hook to prevent a conflict with core
// once hook_entity_duplicate() is introduced there.
$event = new EntityDuplicateEvent($entity, $this->sourceEntity);
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */
$event_dispatcher = \Drupal::service('event_dispatcher');
$event_dispatcher
->dispatch(EntityEvents::ENTITY_DUPLICATE, $event);
}
}