How do I correctly set up the service container in my Symfony 2 application to support custom Document repositories?
What I have so far is:
services:
acme.repository_user:
class: Acme\Repository\UserRepository
arguments: [@doctrine.odm.mongodb.document_manager]
However, when I look at the constructor of the DocumentRepository
class, of which my UserRepository
inherits, I can see the following arguments:
public function __construct(DocumentManager $dm, UnitOfWork $uow, Mapping\ClassMetadata $class)
I seem to have injected the document manager but how do I inject the Unit of Work and the class meta data?
Try to define service as(sorry for xml):
<service id="acme.repository_user"
class="Acme\Repository\UserRepository"
factory-service="doctrine.odm.mongodb.document_manager"
factory-method="getRepository"
public="false">
<argument>AcmeBundle:User</argument>
</service>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With