Roave / psr-container-doctrine

Doctrine Factories for PSR-11 Containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DriverFactory doesn't work with Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain

MuntzMathias opened this issue · comments

Hello

I'm switching between the repository of Dasprid and that of Roave.
I have the following configuration for the configuration of my entityManager.

use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;

return [
    'driver' => [
        'domain' => [
            'class' => MappingDriverChain::class,
            'drivers' => [
                'Domain' => 'domain_entity'
            ],
        ],
        'domain_entity' => [
            'class' => XmlDriver::class,
            'paths' => __DIR__ . '/../src/Infrastructure/Mapping',
        ]
    ]
];

When I instantiate the entityManager I get the following error: (For information it worked correctly with Dasprid services)
The class 'Domain\Account\Entity\User' was not found in the chain configured namespaces.

If I understand correctly, the problem comes from the Factory DriverFactory
which tests if the driver and type is an instance Doctrine\Persistence\Mapping\Driver\MappingDriverChain and not an instance of Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain as described in the example of minimal configuration

Except I do not use the Doctrine\Persistence library, it is also not required in the composer.
So, what should I do ? Install 'Doctrine\Persistence' and use it in my configuration ?

Thank you in advance for your help.

IIRC, this changed because MappingDriverChain changed namespace; I think the solution is indeed to add doctrine/persistence, but without investigating further I don't know why it wouldn't already be required (maybe do a composer update --with(-all)-dependencies to pick it up?).

The example definitely needs updating though, so that needs updating.

Thank you for the answer. Indeed, I cleaned up my composer.json, it contained a dependency on doctrine/orm:^2.7.
I deleted it and completely recreated the vendor, it installed the doctrine/persistence package.
I use it now in my configuration file and it works.