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 think I would prefer to use get() instead of getService() for better consistency (because get() is the method defined in the ContainerInterface):

$this->get('mailer')
$this->container->get('mailer')

We can also add has:

$this->has('mailer')
$this->container->has('mailer')

So, the $this->get('mailer') will be what we use when introducing Symfony2 controllers, and $this->container->get('mailer') will be what you should use as a best practice.

What do you think?

Fabien

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]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to