How to override bundled Doctrine repository in Symfony
<p>I have an independent Symfony bundle (installed with Composer) with entities and repositories to share between my applications that connect same database. </p>

<p>Entities are attached to every applications using configuration (yml shown):</p>

<pre><code>doctrine:
    orm:
        mappings:
            acme:
                type: annotation
                dir: %kernel.root_dir%/../vendor/acme/entities/src/Entities
                prefix: Acme\Entities
                alias: Acme
</code></pre>

<p>Well, it was the easiest way to include external entities in application, but looks a bit ugly. </p>

<p>Whenever I get repository from entity manager:</p>

<pre><code>$entityManager-&gt;getRepository('Acme:User');
</code></pre>

<p>I get either preconfigured repository (in entity configuration) or default <code>Doctrine\ORM\EntityRepository</code>.</p>

<p><strong>Now I want to override bundled (or default) repository class for a single entity. Is there any chance to do it with some configuration/extension/etc?</strong> </p>

<p>I think, the best looking way is something like:</p>

<pre><code>doctrine:
    orm:
         ....:
             Acme\Entities\User:
                 repositoryClass: My\Super\Repository
</code></pre>

<p>Or with tags:</p>

<pre><code>my.super.repository:
    class: My\Super\Repository
    tags:
        - { name: doctrine.custom.repository, entity: Acme\Entities\User }
</code></pre>