public function EntityDuplicateSubscriber::onEntityDuplicate in Entity API 8
Duplicates bundle fields and displays.
Parameters
\Drupal\entity\Event\EntityDuplicateEvent $event: The entity duplicate event.
File
- src/
EventSubscriber/ EntityDuplicateSubscriber.php, line 45
Class
Namespace
Drupal\entity\EventSubscriberCode
public function onEntityDuplicate(EntityDuplicateEvent $event) {
$entity = $event
->getEntity();
if ($entity
->getEntityType()
->getBundleOf()) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $source_entity */
$source_entity = $event
->getSourceEntity();
$this->bundleEntityDuplicator
->duplicateFields($source_entity, $entity
->id());
$this->bundleEntityDuplicator
->duplicateDisplays($source_entity, $entity
->id());
}
}