If the module doesn't return anything, pass the return array instead

Now you can set variables in the module itself and have them returned to the template instead of needing to explicitly return the data. Will come in handy in scenarios where you've extended another module and want to retain it's return data. Previously you had to set a variable and then add to that and return it from the child class.
This commit is contained in:
Josh Sherman 2012-10-14 18:08:27 -04:00
parent 3c2c936cee
commit 8fb7622061
3 changed files with 56 additions and 6 deletions

View file

@ -368,7 +368,17 @@ class Controller extends Object
* module know to use the cache, either passing in a variable
* or setting it on the object
*/
$display->setModuleReturn($valid_request && $valid_security_hash ? $module->__default() : array('status' => 'error', 'message' => $error_message));
if ($valid_request && $valid_security_hash)
{
$module_return = $module->__default();
if ($module_return === null)
{
$module_return = $module->return;
}
}
$display->setModuleReturn(isset($module_return) ? $module_return : array('status' => 'error', 'message' => $error_message));
unset($error_message);