1
votes

I am using the sonata-project/doctrine-phpcr-admin bundle in my symfony cmf app, and need to call an external library in the postPresist action which requires the phpcr document manager.

So my questions is, is there a way to retrieve the phpcr-odm document manager (type Doctrine\ODM\PHPCR\DocumentManager) within a sonata admin class (type Sonata\AdminBundle\Admin\Admin)??

Any info will be greatly appreciated.

1

1 Answers

4
votes

Your admins are services and they have a constructor, so you are free to add your own things to the constructor and inject.

In the case of the document manager, you should however use what is already provided - this is the most clear as then you know you get the correct manager in case of having configured more than one. There is Admin::getModelManager() that will give you a Sonata\DoctrinePHPCRAdminBundle\Model\ModelManager and on that you can call getDocumentManager to get the document manager.