/**
* Execute a task by triggering a method in the derived class.
*
* @param string $task The task to perform. If no matching task is found, the '__default' task is executed, if defined.
*
* @return mixed The value returned by the called method.
*
* @since 3.0
* @throws \Exception
*/
public function execute($task)
{
$this->task = $task;
$task = strtolower((string) $task);
if (isset($this->taskMap[$task])) {
$doTask = $this->taskMap[$task];
} elseif (isset($this->taskMap['__default'])) {
$doTask = $this->taskMap['__default'];
} else {
throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_TASK_NOT_FOUND', $task), 404);
}
// Record the actual task being fired
$this->doTask = $doTask;
return $this->{$doTask}();
}