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