I tend to agree with Benjamin. Even if the intention is to insulate the beginner from the DIC for as long as possible, the documentation necessary to explain ->getService() seems more straightforward than the array syntax. I can also see beginners starting to use the [] in the wrong places (different classes) because were teaching them to use it. In such a case, the error would be less clear than "undefined method getService" or, worse, would "work", but do something besides return a DIC service. The "getService()" would be a great spot to quickly mention the idea of a container containing important objects and then move on. For more advanced users, we've done them a favor by not hiding details.
Thanks @weaverryan On Nov 1, 2010 8:11 AM, "Benjamin Eberlei" <[email protected]> wrote: > Hello, > > I just stumbled over this again in the docs and in some code, i think > the notation $this['servicename'] inside controllers is confusing. I > know its probably there to simplify beginners exposure to the DI > Container, however the notation looks very strange and i have never seen > that usage of ArrayAccess before. I am not sure its very helpful to > beginners. > > Wouldn't a simple method "getService($name)" inside the controller be > much more explicit and understandable from anyones perspective? > > greetings, > Benjamin > > > > -- > 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]<symfony-devs%[email protected]> > For more options, visit this group at > http://groups.google.com/group/symfony-devs?hl=en -- 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
