
Originally Posted by
kyberfabrikken
Well ... how often do you actually need that ?
Maybe you're right, I can't actually of too many cases where this would be needed, but I like the idea 

Originally Posted by
kyberfabrikken
Anyway - The individual Action could create other Action's and execute them. Like ;
Yes, but then you would have to create a new action for every combination of actions you want to execute. If the actions were instead pushed into some kind of an ActionChain and get executed one by one...
PHP Code:
class ActionChain
{
var $actions = array();
function register(&$actionInstance)
{
$this->actions[] = $actionInstance;
}
function execute()
{
for ($i = 0; $i = count($this->actions); $i++)
$this->actions[$i]->execute();
}
Just a thought.
Anyhow, regarding your code, it doesn't seem good to have markup in the actions. Instead, I think each action should import a template and assign variables to it, thus letting each action be a mini-controller. It would also be an appropriate place to put formvalidation. For instance:
PHP Code:
class FooAction extends Action
{
function execute(&$request, &$response)
{
if (isFormValid())
{
$template = new Template('valid.tpl');
$template->assign('result', 'The form has been successfully posted');
$response->setContent($template->getContent());
}
else
{
$template = new Template('invalid.tpl');
$template->assign('result', 'Something bad happened');
$response->setContent($template->getContent());
}
}
}
Bookmarks