title: Symfony PHP Event Listener not working
body: <p>I have a system where a user can create an order. As soon as the order is created another entity table should be updated with the current user who created the order, the time he created it, and some other information.</p>
  
  <p>Basically a Log.</p>
  
  <p>Here is my Listener class;</p>
  
  <pre><code>namespace Qi\Bss\BaseBundle\Lib\PurchaseModule;
  
  use Qi\Bss\BaseBundle\Entity\Business\PurchaseModule\PmodLog;
  use Qi\Bss\BaseBundle\Entity\Business\PurchaseModule\PmodOrder;
  
  use Doctrine\ORM\Event\LifecycleEventArgs;
  
  /**
   * Class OrderLogger. Purchase Module activity logger.
   */
  class OrderLogger
  {
      /**
       * Service container
       * @var type 
       */
      private $serviceContainer;
  
      /**
       * Performs tasks before destruction
       * @ORM\PostPersist
       */
      public function postPersist(LifecycleEventArgs $args)
      {
          $order = $args-&gt;getEntity();
  
          if ($order instanceof PmodOrder) {
              $logRecord = new PmodLog();
  
              $user = $this-&gt;serviceContainer-&gt;get('security.token_storage')-&gt;getToken()-&gt;getUser();
  
              $logRecord-&gt;setCreatedBy($user);
              $logRecord-&gt;setAction('Gemaak');
              $logRecord-&gt;setCreatedAt(new \DateTime());
              $logRecord-&gt;setOrder($order);
              $logRecord-&gt;setDepartment($user-&gt;getDepartment());
          }
      }
  
      /**
       * Sets the sales order exporter object
       * @param type $serviceContainer
       */
      public function setServiceContainer($serviceContainer)
      {
          $this-&gt;serviceContainer = $serviceContainer;
      }
  }
  </code></pre>
  
  <p>I don't get what I'm doing wrong and that the log table in my database doesn't get updated whatsoever.</p>
  
  <p>Here is my service as well;</p>
  
  <pre><code>bss.pmod.logger:
      class: Qi\Bss\BaseBundle\Lib\PurchaseModule\OrderLogger
      calls:
      - [ setServiceContainer, [@service_container] ]
      tags:
          - { name: doctrine.event_listener, event: postPersist }
  </code></pre>
  
  <p>I don't get an error, the order is perfectly created but the log database remain empty.</p>