I structured my sf1.0 actions in this way, suffixing my execute  
methods with either Get or Post. I found this worked very nicely with  
the 1.0 post-back pattern and validation system.

I'm working with 1.2 now and have moved away from post-backs and multi- 
purpose actions. My RESTful routes now target specific actions, ie GET  
-> business/show, POST -> business/create, PUT -> business/update,  
DELETE -> business/delete.

Using different actions for different methods is easy to configure in  
routing.yml and keeps the controller nice and thin, which seems to be  
what you're going for here.

-1

Kris

On Oct 16, 2008, at 3:22 AM, Marijn Huizendveld <[EMAIL PROTECTED] 
 > wrote:

> Hi everybody,
>
> Last week I was thinking about the way sfActions and sfAction work  
> in relation to the new options for creating RESTful controllers with  
> symfony 1.2.
>
> I would like to propose the following API for sfActions to remove  
> some redundant code in my sfAction sub-classes:
>
> Currently if you want to ensure that the controller is only  
> processed given a certain HTTP method you use:
>
> class BlogPostActions extends sfActions
> {
>
>   //...
>
>   public function executeUpdate ($Request)
>   {
>     if ($Request->isMethod('post'))
>     {
>       //POST action here..
>     }
>     elseif ($Request->isMethod('put'))
>     {
>       //PUT action here..
>     }
>     elseif ($Request->isMethod('get'))
>     {
>       //GET action here..
>     }
>   }
>
>   //...
>
> }
>
> I think that it would be great if we could just create different  
> controllers for each type with backwards compatibility like this:
>
> class BlogPostActions extends sfActions
> {
>
>   //...
>
>   public function executeUpdatePost ($Request)
>   {
>     //POST action here..
>   }
>
>   public function executeUpdateGet ($Request)
>   {
>     //GET action here..
>   }
>
>   public function executeUpdatePut ($Request)
>   {
>     //PUT action here..
>   }
>
>   public function executeEdit ($Request)
>   {
>     //and it is backwards compatible
>   }
>
>   //...
>
> }
>
> Especially with the new Form Framework this can save some lines of  
> code and perhaps make it more readable as well (I think readability  
> is a personal preference..).
>
> To implement this I've allready created a new version of the method  
> sfActions::execute() that dispatches the request to the right  
> controller. Unfortunately this is not sufficient for implementing  
> the behavior, sfController::controllerExistst() needs to be altered  
> as well. Hopefully I have some time next week to finish that method  
> as well.
>
> I will certainly use it myself but I was wondering if I should  
> propose this as a behavior for symfony 1.2...
>
> What do you guys think?
>
> Marijn
>
> >

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