/**
* Dispatch a controller task. Redirecting the user if appropriate.
*
* @return void
*
* @since 4.0.0
*/
public function dispatch()
{
// Check component access permission
$this->checkAccess();
$command = $this->input->getCmd('task', 'display');
// Check for a controller.task command.
if (strpos($command, '.') !== false) {
// Explode the controller.task command.
list($controller, $task) = explode('.', $command);
$this->input->set('controller', $controller);
$this->input->set('task', $task);
} else {
// Do we have a controller?
$controller = $this->input->get('controller', 'display');
$task = $command;
}
// Build controller config data
$config['option'] = $this->option;
// Set name of controller if it is passed in the request
if ($this->input->exists('controller')) {
$config['name'] = strtolower($this->input->get('controller'));
}
// Execute the task for this component
$controller = $this->getController($controller, ucfirst($this->app->getName()), $config);
$controller->execute($task);
$controller->redirect();
}