title: Doctrine event listener "..." must specify the "event" attribute
body: <p>I want to register Doctrine Event Listener to hash user's password before persisting <code>User</code> object to database:</p>
  
  <p>This is my Event Listener class:</p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Doctrine;
  
  use AppBundle\Entity\User;
  use Doctrine\Common\EventSubscriber;
  use Doctrine\ORM\Event\LifecycleEventArgs;
  use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  
  class HashPasswordListener implements EventSubscriber
  {
      private $passwordEncoder;
  
      public function __construct(UserPasswordEncoderInterface $passwordEncoder)
      {
          $this-&gt;passwordEncoder = $passwordEncoder;
      }
  
      public function getSubscribedEvents()
      {
          return ['prePersist', 'preUpdate'];
      }
  
      public function prePersist(LifecycleEventArgs $args)
      {
          $entity = $args-&gt;getEntity();
  
          if (!$entity instanceof User) {
              return;
          }
  
          $this-&gt;encodePassword($entity);
      }
  
      /**
       * @param User $entity
       */
      private function encodePassword(User $entity)
      {
          $encoded = $this-&gt;passwordEncoder-&gt;encodePassword($entity, $entity-&gt;getPlainPassword());
          $entity-&gt;setPassword($encoded);
      }
  
      public function preUpdate(LifecycleEventArgs $args)
      {
          $entity = $args-&gt;getEntity();
  
          if (!$entity instanceof User) {
              return;
          }
  
          $this-&gt;encodePassword($entity);
      }
  }
  </code></pre>
  
  <p>And I register this event listener in <code>services.yml</code> file</p>
  
  <pre><code>    AppBundle\Doctrine\HashPasswordListener:
      tags: ['doctrine.event_listener']
  </code></pre>
  
  <p>But whenever I want to insert a user either by loading fixtures data or from the web application I receive such an error:</p>
  
  <pre><code>[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
    Doctrine event listener "AppBundle\Doctrine\HashPasswordListener" must specify the "event" attribute.
  </code></pre>
  
  <p>I tried to add event attribute in <code>tags</code> that didn't work either.</p>
  
  <p>I'm using Symfony version 3.3 with Doctrine 2.5</p>
  
  <p>Configured Doctrine in <code>config.yml</code> so:</p>
  
  <pre><code>doctrine:
  dbal:
      driver: pdo_sqlite
      path: '%kernel.project_dir%/app/sqlite.db'
      charset: UTF8
  </code></pre>
  
  <p>Where is the fault?</p>