vendor/kunstmaan/admin-bundle/EventListener/CloneListener.php line 14

Open in your IDE?
  1. <?php
  2. namespace Kunstmaan\AdminBundle\EventListener;
  3. use Kunstmaan\AdminBundle\Entity\AbstractEntity;
  4. use Kunstmaan\AdminBundle\Entity\DeepCloneInterface;
  5. use Kunstmaan\AdminBundle\Event\DeepCloneAndSaveEvent;
  6. /**
  7.  * This listener will make sure the id isn't copied for AbstractEntities
  8.  */
  9. class CloneListener
  10. {
  11.     public function onDeepCloneAndSave(DeepCloneAndSaveEvent $event)
  12.     {
  13.         $clonedEntity $event->getClonedEntity();
  14.         if ($clonedEntity instanceof AbstractEntity) {
  15.             $clonedEntity->setId(null);
  16.         }
  17.         if ($clonedEntity instanceof DeepCloneInterface) {
  18.             $clonedEntity->deepClone();
  19.         }
  20.     }
  21. }