I want to use MongoDB for storing sessions, and I need to inject the \Mongo
object into the session handler.
I first thought I could fetch it from doctrine with something like this:
services:
mongo.connection:
class: MongoDoctrine\MongoDB\Connection
factory_service: doctrine.odm.mongodb.document_manager
factory_method: getConnection
mongo:
class: Mongo
factory_service: mongo.connection
factory_method: getMongo
But it throws a circular reference exception due to a logger preprocessor I'm using that needs the request_id I think, and even if I turn that off, sometimes it returns null. So then I just instantiated my own instance of Mongo and worked fine:
services:
mongo:
class: Mongo
arguments: [ %doctrine_mongodb.default_server% , %doctrine_mongodb.options% ]
Can there be a problem with this? I mean doctrine and the session handler will be using two different instances of \Mongo
.
Any ideas on how to get the reference to the \Mongo
object created by doctrine without falling into a circular reference?