title: How to resolve "Circular reference detected for service" issue?
body: <p>I'm trying to inject my repository service into EventListener but that leads me to following exception, which, with my basic knowledge of Symfony2, I have no idea how to resolve. Exception is:</p>
  
  <blockquote>
    <p>ServiceCircularReferenceException in bootstrap.php.cache line 2129:</p>
    
    <p>Circular reference detected for service  "doctrine.orm.default_entity_manager", path: "doctrine.orm.default_entity_manager -> doctrine.dbal.default_connection -> person.connect.listener -> tag.repository.service".</p>
  </blockquote>
  
  <p>And here is how I've declared repository and listener:</p>
  
  <pre><code>tag.repository.service:
      class: Application\Bundle\PersonBundle\Entity\TagRepository
      factory: ["@doctrine", getRepository]
      arguments: [ Application\Bundle\PersonBundle\Entity\Tag ]
  
  person.connect.listener:
      class: Application\Bundle\PersonBundle\EventListener\ConnectListener
      arguments:
          tokenStorage: "@security.token_storage"
          tagRepo: "@tag.repository.service"
      tags:
          - { name: doctrine.event_listener, event: postPersist, connection: default }
  </code></pre>
  
  <p>Most answers, that I've able to find, suggest injecting service container, but I really don't want do that. Is there any way to resolve this properly?</p>
  
  <p>UPD: Here is the code of the listener. Everything worked fine until I've tried to inject TagRepository</p>
  
  <pre><code>class ConnectListener
  {
  /**
   * @var TokenStorage
   */
  private $tokenStorage;
  
  /**
   * @var TagRepository
   */
  private $tagRepo;
  
  /**
   * @param TokenStorage $tokenStorage
   * @param TagRepository $tagRepo
   */
  public function __construct(TokenStorage $tokenStorage, TagRepository $tagRepo)
  {
      $this-&gt;tokenStorage = $tokenStorage;
  }
  /**
   * @param LifecycleEventArgs $args
   * @return void
   */
  public function postPersist(LifecycleEventArgs $args)
  {
      $entity = $args-&gt;getEntity();
      $entityManager = $args-&gt;getEntityManager();
  
      if ($entity instanceof Person) {
          $user = $this-&gt;tokenStorage-&gt;getToken()-&gt;getUser();
          $visibility = new PersonVisibility($entity, $user);
          $visibility-&gt;setVisibilityType(PersonVisibility::VT_CREATED);
          $entityManager-&gt;persist($visibility);
          $entityManager-&gt;flush();
      }
  }
  }
  </code></pre>