CoreFiles by mySites.guru
Dispatcher.php87 lines, 2,431 bytes, from Joomla_6.1.2-Stable-Full_Package.zip
Raw History Compare with 6.1.1
md5
902f52d10ef3123092bf1899dd190f38
sha1
9ca356666b48387886311cfde74629f1e7905366
sha256
dce908d94ab7ee7e90e40dec0fa228eef3dc087d02ae54c6e445afdd39861d8e
<?php

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

namespace Joomla\Component\Workflow\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_contenthistory
 *
 * @since  6.1.0
 */
class Dispatcher extends ComponentDispatcher
{
    /**
     * Load the language
     *
     * @since   6.1.0
     *
     * @return  void
     */
    protected function loadLanguage()
    {
        // Load common and local language files.
        $this->app->getLanguage()->load($this->option, JPATH_ADMINISTRATOR) ||
        $this->app->getLanguage()->load($this->option, JPATH_SITE);
    }

    /**
     * Method to check component access permission
     *
     * @since   6.1.0
     *
     * @return  void
     *
     * @throws  \Exception|NotAllowed
     */
    protected function checkAccess()
    {
        $input      = $this->app->getInput();
        $view       = $input->getCmd('view');
        $task       = $input->getCmd('task');

        $allowedTasks = [
            'graph.getWorkflow',
            'graph.getStages',
            'graph.getTransitions',
        ];

        // Check the user has permission to access this component if in the backend
        if ($this->app->getIdentity()->guest || $view !== 'graph' || !\in_array($task, $allowedTasks, true)) {
            throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
        }
    }

    /**
     * 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  BaseController
     *
     * @since   6.1.0
     */
    public function getController(string $name, string $client = '', array $config = []): BaseController
    {
        $config['base_path'] = JPATH_ADMINISTRATOR . '/components/com_workflow';
        $client              = 'Administrator';

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

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