/**
* Dispatch a controller task. Redirecting the user if appropriate.
*
* @return void
*
* @since 4.0.0
*/
public function dispatch()
{
$path = JPATH_COMPONENT . '/' . substr($this->app->scope, 4) . '.php';
// If component file doesn't exist throw error
if (!is_file($path)) {
throw new \Exception(Text::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
}
$lang = $this->app->getLanguage();
// Load common and local language files.
$lang->load($this->app->scope, JPATH_BASE) || $lang->load($this->app->scope, JPATH_COMPONENT);
// Execute the component
$loader = static function ($path) {
require_once $path;
};
$loader($path);
}