On Sun, Mar 21, 2010 at 2:49 PM, Fabian Lange <[email protected]> wrote: > public function setContainer(Container c) { > $this->userService = c->getService('user.session.pdo'); > } > > This way would eliminate all magic and be pretty much the way the > pattern is implemented in many Java frameworks.
This sounds verbose for no real benefit, if you pass services in the constructor, you don't have any magic apart from basic reflection. You can also pass nulls or whatever you want in tests without needing to fake or tweak a container. If you add on top of that the approach I suggested [1] and use $_Service or the like in methods as an optional way to get extra services, this is seemingly magic but not really. The complete functionality can be achieved normally through the constructor for people that don't know about the magic part, and the magic is just added sugar. [1] http://groups.google.com/group/symfony-devs/msg/e078cdf9015fc1c5 Cheers, Jordi -- 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 developers" 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-devs?hl=en To unsubscribe from this group, send email to symfony-devs+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
