CoreFiles by mySites.guru
Dispatcher.php78 lines, 1,998 bytes, from Joomla_6.2.0-Stable-Full_Package.zip
Raw History Compare with 6.1.4
md5
c380b62cbbebd34fd0b76f0653876b0d
sha1
4e0ae966b212b5541dde09b92997ad3e1780e119
sha256
f03ac5f511b158f3dd4d45369a0b88571315a3bae0c93876b09981e4ace1de76
<?php

/**
 * @package     Joomla.Site
 * @subpackage  com_modules
 *
 * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Modules\Site\Dispatcher;

use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Dispatcher\ComponentDispatcher;
use Joomla\CMS\MVC\Controller\BaseController;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * ComponentDispatcher class for com_modules
 *
 * @since  4.0.0
 */
class Dispatcher extends ComponentDispatcher
{
    /**
     * Load the language
     *
     * @since   4.0.0
     *
     * @return  void
     */
    protected function loadLanguage()
    {
        $this->app->getLanguage()->load('com_modules', JPATH_ADMINISTRATOR);
    }

    /**
     * Dispatch a controller task. Redirecting the user if appropriate.
     *
     * @return  void
     *
     * @since   4.0.0
     */
    public function checkAccess()
    {
        parent::checkAccess();

        if (
            !$this->app->getIdentity()->authorise('module.edit.frontend', 'com_modules')
        ) {
            throw new NotAllowed();
        }
    }

    /**
     * Get a controller from the component
     *
     * @param   string  $name    Controller name
     * @param   string  $client  Optional client (like Administrator, Site etc.)
     * @param   array   $config  Optional controller config
     *
     * @return  \Joomla\CMS\MVC\Controller\BaseController
     *
     * @since   4.0.0
     */
    public function getController(string $name, string $client = '', array $config = []): BaseController
    {
        if ($this->input->get('task') === 'orderPosition') {
            $config['base_path'] = JPATH_ADMINISTRATOR . '/components/com_modules';
            $client              = 'Administrator';
        }

        return parent::getController($name, $client, $config);
    }
}

The same content is in 20 releases, Joomla 5.4.8-rc1 to 6.2.1-rc1. See them all, or every version of this file.