Skip to content

Commit

Permalink
Fix dispatcher to use the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Nov 18, 2017
1 parent 670c076 commit 4cd835a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions components/com_contenthistory/dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function checkAccess()
}

/**
* Get a controller from the component
* Get a controller from the component. We want to proxy everything to the backend.
*
* @param string $name Controller name
* @param string $client Optional client (like Administrator, Site etc.)
Expand All @@ -71,8 +71,20 @@ protected function checkAccess()
*/
public function getController(string $name, string $client = '', array $config = array()): BaseController
{
// Set up the namespace
$namespace = rtrim($this->namespace, '\\') . '\\';

// Set up the client
$app = \Joomla\CMS\Application\CMSApplication::getInstance('Administrator');

$controllerClass = $namespace . 'Administrator\\Controller\\' . ucfirst($name) . 'Controller';
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;

return parent::getController($name, $client, $config);
if (!class_exists($controllerClass))
{
throw new \InvalidArgumentException(\JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $controllerClass));
}

return new $controllerClass($config, new \Joomla\CMS\MVC\Factory\MVCFactory($namespace, $app), $app, $this->input);
}
}

0 comments on commit 4cd835a

Please sign in to comment.