Hi all, I'm having some issues with service scoping. I'll try to describe my situation the best I can. If something is not clear, please tell me :).
Having this base classes: , Module (which can have services) . Service (which can have other services) I could have something like this: UserModule has a UserService, which can have a ContactInformationService. ContactInformationModule has another instance of ContactInformationService. So, for the first case, I define in the DIC a "user_module" service, a "user_service", and a "contact_information_service". Then, in the "user_module"'s definition, I add the "user_service" to the "user_module" with a call to a Module's method called "addService". Finally, in the "user_service"'s definition, I add to it the sub-service "contact_information_service" with a call to the method "addService". My problem: Each Module should be instantiated only once. This is OK. But each Service should be instantiated once per Module and each time it's been added to a service, as a sub-service. This is because each service can have a different state, depending on if it's a subservice or not. So, I tried to change the scope of my services to "prototype" to accomplish this. But then I received the following error: *"Scope Crossing Injection detected: The definition "module_manager.module.user" references the service "module_manager.module.user.service" which belongs to another scope hierarchy. This service might not be available consistently. Generally, it is safer to either move the definition "module_manager.module.user" to scope "prototype", or declare "container" as a child scope of "prototype". If you can be sure that the other scope is always active, you can set the reference to strict=false to get rid of this error"* I tried to use strict="false" but then I've got an infinite recursion problem. Is my approach correct in terms of the DIC? I mean, is it possible to have, in one hand, one service with scope="container" and add to it services with scope="prototype" and, in the other hand, have a service with scope="prototype" and add to it another service with the same scope? I hope I'm clear. If not, please tell me. Thanks! -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
