On 11/1/10 10:17 PM, Lukas Kahwe Smith wrote:
On 01.11.2010, at 21:52, ryan weaver <[email protected]
<mailto:[email protected]>> wrote:

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.

I agree as well.

I would like to take things a bit further even. I agree that for many
 beginners the DIC should not be the first thing they deal with. But
I also think that its pointless to do real work with Symfony2 without
 learning about the DIC. So imho the base Controller class, the
service-less Controller setup etc is all training-wheel stuff that
you use to slowly introduce all the concepts.

But Bundles and actual production code should not use the Base
Controller class. The little code there currently is that isnt just
delegating into a service instance should be moved accordingly.

That's how it's done already. If you have a look at the Controller base class, you will see that it only contains shortcut methods. As a matter of fact, no controllers in the core framework extend this class.

To make it clear, I have just updated the best practice documentation accordingly:

http://github.com/symfony/symfony-docs/commit/ca4a543648bb42413208137f6dc8062080c15cbd

Fabien

regards Lukas

--
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