Reputation: 1566
I'm working on auth system in silex using doctrine orm, and in this doc http://silex.sensiolabs.org/doc/providers/security.html#defining-a-custom-user-provider below schema there is info sounds like that:
"If you are using the Doctrine ORM, the Symfony bridge for Doctrine provides a user provider class that is able to load users from your entities."
I'm using Dotrine ORM provider so I decied to use EntityUserProvider class for that from Symfony\Bridge\Doctrine\Security\User and the problem is the constructor of this class as the first argument has "ManagerRegistry $registry".
What I should put there from silex ? Is there dedicated service or object for that?
Upvotes: 4
Views: 836
Reputation: 672
In a Symfony2 context and according to the Doctrine and Symfony Doctrine Bridge source code, you would need to inject the service called doctrine
which takes a connection
, an entity manager
, the default connection
and the default entity manager
as arguments. This service is defined in vendor\{...}\Doctrine\Bundle\DoctrineBundle\Resources\config\dbal.xml
.
(This service is an instance of Doctrine\Bundle\DoctrineBundle\Registry
which extends the abstract class Symfony\Bridge\Doctrine\ManagerRegistry
that extends the Doctrine\Common\Persistence\AbstractManagerRegistry
that finally implements the interface Doctrine\Common\Persistence\ManagerRegistry
which is the type hinted class.)
As mentioned in the first few lines of the Silex providers documentation according Doctrine, the ORM service is not supplied. Since you are using a custom provider to use the ORM, you need to inject the equivalent to this doctrine
service.
Upvotes: 1