class AddCallback extends AgaviRoutingCallback
{
public function onMatched(array &$parameters, AgaviExecutionContainer $container)
{
# 1. find out Model we are dealing with, eg. Products/Promotions
$model = new Products;
try {
$model->add($parameters['form']);
$this->flash("Added {$model}!");
$return = 'Success';
} catch(Exception $e) {
$return = 'Error';
$this->flash($e->getMessage());
}
# 2. further processing:
if(file $model."Action" exists)
goto Action # more custom Add logic for this model
elseif(file $model.$return."View" exists)
goto View # more custom View logic for this model
else
goto $return."Template"
return true;
}
}