[Solar-talk] Method-Based Actions

Paul M Jones pmjones at ciaweb.net
Fri Jun 23 07:58:44 PDT 2006


Hi guys,

We had a talk about file-based controller actions vs. method-based  
actions back in March, starting with the Solar 0.14.0 release  
discussion and continuing into a new thread:

     http://mail.killersoft.com/pipermail/solar-talk/2006-March/ 
000693.html

     http://mail.killersoft.com/pipermail/solar-talk/2006-March/ 
000712.html

Everyone in those threads except me figured that methods were the  
better approach, for various reasons: Antti, Arnaud, Matthew, and  
Travis.  Guys, you were right: methods are better for a number of  
reasons, which I will detail below.

With that in mind, I spent yesterday updating Solar_Controller_Page  
to use action methods instead of action files, and have updated  
Solar_App_Hello and Solar_App_Bookmarks to use the new page- 
controller.  You can see them in SVN right now:

     http://solarphp.com/svn/trunk/Solar/Controller/Page.php
     http://solarphp.com/svn/trunk/Solar/App/Bookmarks.php
     http://solarphp.com/svn/trunk/Solar/App/Hello.php

This has several ramifications:

# Instead of having "Actions/example.action.php", you now have an  
"exampleAction()" method in the page controller.

# As a result, there is no longer any need for the $_action_info  
action-to-info mapping array.  The action-info mapping would set up,  
e.g., 'example' => 'foo/bar/baz' so that $_info would be populated  
with named parameters based on the action requested.  With method- 
based actions, those are automatically determined by the method  
parameters, e.g. function exampleAction($foo = null, $bar = null,  
$baz = null).

# Using method-based actions makes for much easier documentation  
generation, and will lead to easier testing later on.

I'll include more information in the release notes when Solar 0.20.0  
comes out; I am preparing the release right now.

Let me know if you have questions, comments, etc., and thanks for  
your patience in waiting for me to "come around" to this way of  
thinking.


--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.   <http://solarphp.com>

Savant: The simple, elegant, and powerful solution for
templates in PHP.   <http://phpsavant.com>




More information about the solar-talk mailing list