Okay I've began setting up my Controllers as a service so I can inject 
services into the constructor rather than relying on ContainerAware and 
getting services from that. I prefer this method. Class type restriction in 
the constructor, making good informed decisions about services you are going 
to make, and IDE help...among other things..etc

However I am worried about having optional services in my Controller adding 
unneeded overhead and based on the Symfony2 from the trenches talk I am not 
alone. To quote:

*Do not explicitly inject optional services to controllers:
*
*If your controller receives many services, which are optional or unused by 
some actions, that's probably a hint that you should break it up into 
multiple controllers*

Now taking a simple CRUD controller.

//These really only add things to the session and redirect. Using liip view 
for json/xml handling
deleteAction()  //services liip_view, doctrine.odm.mongodb.document_manager, 
session
createAction()  //services liip_view, doctrine.odm.mongodb.document_manager, 
form.context, session, request
updateAction() //services liip_view, doctrine.odm.mongodb.document_manager, 
form.context, session, request

//These render stuff
newAction()     //services liip_view, form.context
viewAction()    //services liip_view, doctrine.odm.mongodb.document_manager
listAction()       //services liip_view, 
doctrine.odm.mongodb.document_manager, knplabs_paginator.adapter

So based on the above advice I could end up with 5 controllers to avoid 
optional services, which seems very silly.

Now is this something I should be worrying about with only 6 services in 
total? 

Should I just get over my aversion to ContainerAware concept and use PHPDoc 
to make my IDE happier?

Should I use Lukas's Container Service Wrapper along with PHPDoc to make me 
and my IDE happier? 
https://github.com/lsmith77/Symfony2-Container-service-wrapper

Opinions on this topic warmly received and thanks to Ornicar talking this 
over with me in the dev channel tonight, and my colleagues for me bothering 
them all day about this probably very minor topic...!

Cheers
John

-- 
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 users" 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-users?hl=en

Reply via email to