There is a mistake in the RFC in Approach 3 "Accessing Services":

In the code example it must be:

$userService->setAttribute(...);


I don't like the "suffix approaches". I also don't know exactly how
the injection currently works. But I have this idea for Approach
7: ;-)

- use Approach 2 for the constructor
- use that rules to inject arguments to the actions:

  - arguments with a class type hint are services
  - all other arguments are routing parameters

Example action:

public function indexAction(Mailer $mailer, $foo)
{
  // $mailer is the mailer service because it has a class type hint
  // $foo is a routing parameter
}


Is that possible? What do you think?

regards,
Matthias



On 25 Mrz., 09:28, Fabien Potencier <fabien.potenc...@gmail.com>
wrote:
> I have just updated the RFC with a new Approach where the routing
> variables are not injected anymore in the action methods 
> (http://www.symfony-reloaded.org/rfc/controllers). Here is the added text:
>
> This approach is the same as Approach 4 except that the routing
> variables
> cannot be injected in the action methods. It allows to remove the need
> for the
> suffixes (Parameter and Service):
>
>     protected $user;
>
>     function __construct(User $user)
>     {
>       $this->user = $user;
>     }
>
>     function showAction($mailer, $maxPerPage)
>     {
>     }
>
> Accessing routing variable values is possible by injecting the Request
> object:
>
>     function showAction(Request $request, $mailer, $maxPerPage)
>     {
>       $id = $request->getPathParameter('id');
>
>       // ...
>     }
>
> A good convention can be to inject the Request object as the first
> argument if
> it is needed in the method (for consistency).
>
> Fabien

-- 
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 symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
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