public function execute($task)
{
$this->task = $task;
if (!isset($this->taskMap[$task]) && !isset($this->taskMap['__default'])) {
throw new TaskNotFound(\JText::sprintf('JLIB_APPLICATION_ERROR_TASK_NOT_FOUND', $task), 404);
}
$result = $this->triggerEvent('onBeforeExecute', array(&$task));
if ($result === false) {
return false;
}
$eventName = 'onBefore' . ucfirst($task);
$result = $this->triggerEvent($eventName);
if ($result === false) {
return false;
}
// Do not allow the display task to be directly called
if (isset($this->taskMap[$task])) {
$doTask = $this->taskMap[$task];
} elseif (isset($this->taskMap['__default'])) {
$doTask = $this->taskMap['__default'];
} else {
$doTask = null;
}
// Record the actual task being fired
$this->doTask = $doTask;
$ret = $this->{$doTask}();
$eventName = 'onAfter' . ucfirst($task);
$result = $this->triggerEvent($eventName);
if ($result === false) {
return false;
}
$result = $this->triggerEvent('onAfterExecute', array($task));
if ($result === false) {
return false;
}
return $ret;
}