title: Do Subscribers work while loading Fixtures in Symfony?
body: <p>I tried to run the fixture below on Symfony 5 using the command <code>php bin/console d:f:l</code>.
  I get this error: <code>SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'contact_email' cannot be null</code></p>
  <p>The same code logic is working fine for Post entities when creating them manually through the CRUD. Are fixtures not compatible with subscribers (events) or did i make a mistake?</p>
  <p>Thank you.</p>
  <p>Edit: I'm also using EasyAdmin Bundle 3.</p>
  <h2>App\DataFixtures.php\AppFixtures.php</h2>
  <pre><code>&lt;?php
  
  namespace App\DataFixtures;
  
  use App\Entity\User;
  use App\Entity\Author;
  use Doctrine\Persistence\ObjectManager;
  use Doctrine\Bundle\FixturesBundle\Fixture;
  use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  
  class AppFixtures extends Fixture
  {
  
      /** @var User[] */
      private $users = [];
  
      /** @var Author[] */
      private $authors = [];
  
      /** @var UserPasswordHasherInterface */
      private $hasher;
  
      public function __construct(UserPasswordHasherInterface $hasher)
      {
          $this-&gt;hasher = $hasher;
      }
  
      public function load(ObjectManager $manager): void
      {
          $this-&gt;createUsers();
          foreach($this-&gt;users as $user) $manager-&gt;persist($user);
  
          $this-&gt;createAuthors();
          foreach($this-&gt;authors as $author) $manager-&gt;persist($author);
  
          $manager-&gt;flush();
      }
  
      public function createUsers(): void
      {
          $admin = (new User)
              -&gt;setUsername('admin')
              -&gt;setEmail('admin@admin.com')
              -&gt;setRoles(['ROLE_ADMIN'])
              -&gt;setFirstname('Edouard')
              -&gt;setLastname('Proust');
          $admin-&gt;setPassword($this-&gt;hasher-&gt;hashPassword($admin, 'admin'));
  
          $this-&gt;users[] = $admin;
      }
  
      public function createAuthors(): void
      {
          foreach($this-&gt;users as $user) {
              if(in_array('ROLE_ADMIN', $user-&gt;getRoles())) {
                  $author = (new Author)
                      -&gt;setUser($user)
                      -&gt;setAvatar('#')
                      -&gt;setBio('Bio')
                      // The line i want to get rid of:
                      // -&gt;setContactEmail($user-&gt;getEmail())
                  ;
  
                  $this-&gt;authors[] = $author;
              }
          }
      }
  
  }
  </code></pre>
  <h2>App\EventListener\AuthorSubscriber.php</h2>
  <pre><code>&lt;?php
  
  namespace App\EventListener;
  
  use App\Entity\Author;
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityPersistedEvent;
  
  class AuthorSubscriber implements EventSubscriberInterface
  {
  
      public static function getSubscribedEvents()
      {
          return [
              BeforeEntityPersistedEvent::class =&gt; 'setContactEmail',
          ];
      }
  
      public function setContactEmail(BeforeEntityPersistedEvent $event)
      {
          
          /** @var Author */
          $entity = $event-&gt;getEntityInstance();
          if($entity instanceof Author) {
              if(!$entity-&gt;getContactEmail()) {
                  $user = $entity-&gt;getUser();
                  $contactEmail = $user ? $user-&gt;getEmail() : '#';
                  $entity-&gt;setContactEmail($contactEmail);
              }
              
          }
      }
  
  }
  </code></pre>