title: Symfony event listener after save new entity
body: <p>I need check if entity is instance of specific entity and do something after save new entity. Something like method afterSave in cakephp. I tried <code>postFlush</code>, <code>onFlush</code>, <code>postPersist</code> and <code>postLoad</code>.</p>
  
  <p>AppBundle/EventListener/DoSomethingAfterSaveNewEntity.php</p>
  
  <pre><code>namespace AppBundle\EventListener;
  
  use Doctrine\ORM\Event\OnFlushEventArgs;
  use AppBundle\Entity\SomeEntity;
  
  class DoSomethingAfterSaveNewEntity 
  {
      public function onFlush(OnFlushEventArgs $args)
      {   
          $entity = $args-&gt;getEntity();
          $em = $args-&gt;getEntityManager();
          $uow = $em-&gt;getUnitOfWork();
  
          if (!$entity instanceof SomeEntity) {
            die('not instance!!!');
          }
  
          die('post flush!!!');
          $entityManager = $args-&gt;getEntityManager();
      }
  }
  </code></pre>