Using Symfony2 and Doctrine ODM with MongoDB, I need to access the parent document from within an embedded document.
I have a 'Cardset' object which has embedMany on 'Card' objects.
The 'Card' object has a 'save image' method and I want that to use the ID of the Cardset object that contains it as part of the path to which it saves.
I can't find a way to access the parent document from within the embeddeddocument.
If I could get hold of an instance of 'DocumentManager', I might be able to use the 'getParentAssociation()' method. But this
$this->get('doctrine.odm.mongodb.document_manager');
doesn't work since it's not inside a Controller. I'm not experienced enough to know how to make the DocumentManager into a service that would be available from inside my object class.
Can anyone help?