Skip to content

Commit

Permalink
Simplify dispatcher code and load language files when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Mar 2, 2018
1 parent d36f931 commit 11db0af
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions libraries/src/Dispatcher/Dispatcher.php
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Form\FormFactoryAwareInterface;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\Input\Input;
Expand Down Expand Up @@ -82,16 +83,11 @@ public function __construct(CMSApplication $app, Input $input = null)
// If option is not provided, detect it from dispatcher class name, ie ContentDispatcher
if (empty($this->option))
{
$className = get_class($this);
$pos = strpos($className, 'Dispatcher');

if ($pos !== false)
{
$this->option = 'com_' . strtolower(substr($className, 0, $pos));
}
$this->option = ComponentHelper::getComponentName(
$this,
strtolower(str_replace('Dispatcher', '', get_class($this)))
);
}

$this->loadLanguage();
}

/**
Expand Down Expand Up @@ -133,6 +129,8 @@ protected function checkAccess()
*/
public function dispatch()
{
$this->loadLanguage();

// Check component access permission
$this->checkAccess();

Expand Down

0 comments on commit 11db0af

Please sign in to comment.