On 22.03.2010 13:52, ever.zet wrote: > >> First, I want to thank you all for taking the time to comment the first RFC. >> After the discussions that took place, I have created a version 2 of the RFC: >> >> http://symfony-reloaded.org/rfc/controllers > > Now i like "Approach 4". It's universal & good enough for all.
I would also favor 4 since it empowers users with a choice (and nobody seems to really agree on one best way). As I already pointed out though, and I don't know why it was left out of the second RFC, service variables in actions really should be pre-fixed, post-fixed, or anything that differentiates them from route variables, and route variables should be prevented to have a name that will conflict with that defined pre/post-fix, so as to avoid any problems (WTFs) when refactoring code. This approach btw allows Fabian to still only inject the container in the constructor and then fetch all services by hand when needed. As for using the pre/post-fix in the constructor variables, I don't see why. The typical use cases I see are those : - Give me the container and I will fetch everything: function __construct($container) function list($id) function read($id) function comment($id, $mailerService) => clean - Give me most of my services in constructor, and every now and then an extra one in the action: function __construct($request, $user, $db) function list($id) function read($id) function comment($id, $mailerService) => there you bloat it a bit in one call, but it's for the sake of performance and should happen rarely - I like long signatures, give me all in every function: function __construct() function list($requestService, $userService, $dbService, $id) function read($requestService, $userService, $dbService, $id) function comment($requestService, $userService, $dbService, $mailerService, $id) => bloated but at least you don't have conflicts If you force the prefix in the constructor you penalize everyone for the rare use case of the (i.e.) mailer. I don't think it's necessary. The way I see it, it's not uncommon to use 5-6 services minimum in every request, be it in the action itself or in some helper you call, so I don't think people will really want to declare them all every time in their actions, then forward them to their helper methods etc.. So the added verbosity sounds alright in that place. Cheers, Jordi
signature.asc
Description: OpenPGP digital signature
