title: Symfony 4 Doctrine EventSubscriber not used
body: <p>Trying to register a Doctrine EventSubscriber but nothing is ever actually fired.</p>
  
  <p>I have, on the Entity, in question, set the <code>@ORM\HasLifeCycleCallbacks</code> annotation.</p>
  
  <p>Here's the Subscriber:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Subscriber;
  
  use App\Entity\User;
  use Doctrine\Common\EventSubscriber;
  use Doctrine\ORM\Event\LifecycleEventArgs;
  use Doctrine\ORM\Event\PreUpdateEventArgs;
  use Doctrine\ORM\Events;
  use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  
  class UserPasswordChangedSubscriber implements EventSubscriber
  {
      private $passwordEncoder;
  
      public function __construct(UserPasswordEncoderInterface $passwordEncoder)
      {
          $this-&gt;passwordEncoder = $passwordEncoder;
      }
  
       public function getSubscribedEvents()
      {
          return [Events::prePersist, Events::preUpdate, Events::postLoad];
      }
  
      public function prePersist(LifecycleEventArgs $args)
      {
          $entity = $args-&gt;getEntity();
  
          if (!$entity instanceof User) {
              return null;
          }
  
          $this-&gt;updateUserPassword($entity);
      }
  
      public function preUpdate(PreUpdateEventArgs $event)
      {
          $entity = $event-&gt;getEntity();
  
          if (!$entity instanceof User) {
              return null;
          }
  
          $this-&gt;updateUserPassword($entity);
      }
  
      private function updateUserPassword(User $user)
      {
          $plainPassword = $user-&gt;getPlainPassword();
  
          if (!empty($plainPassword)) {
              $encodedPassword = $this-&gt;passwordEncoder-&gt;encodePassword($user, $plainPassword);
              $user-&gt;setPassword($encodedPassword);
              $user-&gt;eraseCredentials();
          }
      }
  }
  </code></pre>
  
  <p>The part that is making this particuarly frustrating is that this same code and configuration was fine in Symfony 3 whe autowiring was turned off and I manually coded all my services.</p>
  
  <p>However, now, even if I manually code up a service entry for this, in the usual way, still nothing happens. </p>
  
  <p>EDIT:</p>
  
  <p>Here is my services.yaml after trying what suggested Domagoj from the Symfony docs:</p>
  
  <pre><code>App\Subscriber\UserPasswordChangedSubscriber:
          tags:
              - { name: doctrine.event_subscriber, connection: default }
  </code></pre>
  
  <p>It didn't work. Interestingly, If I un-implement the EventSubscriber interface, Symfony throws an exception (rightly). Yet my break points in the code are completely ignored.</p>
  
  <p>I've considered an EntityListener, but it cannot have a constructor with arguments, doesn't have access to the Container and I shouldn't have to; this ought to work :/</p>