On 11/1/10 2:11 PM, Benjamin Eberlei 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?
I almost forgot something. Right now, there is a symmetry between
controllers and templates in the way you access services and helpers:
// in a controller
$this['mailer']
// in a template
$view['router']
If we were to remove ArrayAccess for controllers, I think it makes sense
to also remove it from the templating system. So, we would have this in
a template:
$view->get('router')
which is more verbose than before and calling helper methods is already
really verbose. So, the new way to generate a link from a template would
be (and no, I'm not advocating Twig here ;)):
$view->get('router')->generate('route_name', array(...))
Any comment? Does it change the conclusion for controllers?
Fabien
--
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