Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DI] Doctrine repositories autowire issue #29810

Copy link
Copy link
Closed
@jkabat

Description

@jkabat
Issue body actions

Symfony version(s) affected: 4.1.10, maybe others

Description
Recent upgrade from v4.1.7 to v4.1.10 causes issue with autowiring of custom doctrine repositories created using code explained at https://symfony.com/doc/4.1/doctrine.html#querying-for-objects-the-repository

Exception thrown:
Argument 1 passed to App\Repository\CouponRepository::__construct() must implement interface Symfony\Bridge\Doctrine\RegistryInterface, instance of Doctrine\ORM\EntityManager given, called in vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php on line 68

How to reproduce
Application repository __construct() arguments are ignored and EntityManager is forcibly injected for all repository services.

use Symfony\Bridge\Doctrine\RegistryInterface;

/**
 * Class CouponRepository
 * @package App\Repository
 */
class CouponRepository extends AbstractRepository
{
    public function __construct(RegistryInterface $registry)
    {
        parent::__construct($registry, Coupon::class);
    }
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;

/**
 * Class AbstractRepository
 * @package App\Repository\Common
 */
abstract class AbstractRepository extends ServiceEntityRepository
{

This is happening even if I manually wire repository with ManagerRegistry service as argument.

Possible Solution
I did not find any solution yet, also haven't figure out which PR caused this behavior - maybe somebody else will have time to investigate. I had to downgrade symfony/dependency-injection package to the previously working one (v4.1.8).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.