Possible changes for PR2
------------------------

Below are my proposals for Symfony 2 PR2.

### Inject the needed services in the constructor

As for the action, we can inject the services in the constructor by using
introspection:

   protected $user, $doctrineManager;

   function __construct($user, $doctrineManager)
   {
     $this->user = $user;
   }

   function showAction($id)
   {
     $this->user->setAttribute(...);
   }

By matching the service name with the argument name, that should be easy and
should only incur a small performance impact.

Problem: The constructor need all services needed by all methods, which is not a good idea (we will create too many services most of the time). And then, it's up to the developer to store the services in protected variables. That
means some boilerplate code.

after a lot snd back and forth this is what we went with in okapi2. we felt that we do not want to go down the path of recursive references. also having to create mock sc instances in testing also didnt seem appealing. the most import point imho was that this way its easy to see the dependencies of action classes quickly. like i said in my presentation at sflive objects need to lazy load as much as possible. but more importantly when different action methods have radically different dependencies then you probably ought to split them into separate actions anyways.

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

To unsubscribe from this group, send email to symfony-devs+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Reply via email to