CoreFiles by mySites.guru
Dispatcher.php53 lines, 1,502 bytes, from Joomla_5.4.11-Stable-Full_Package.zip
Raw History Compare with 5.4.10
md5
46331b0267b2df55e555e9f2a84282bc
sha1
f4820322b84dfdbc079938b610381ce3f9cebd23
sha256
b2c8f2a04597c981f2308b02dfbff4844791fae8adf33d52b2fe4dcf77c8824a
<?php

/**
 * @package     Joomla.Api
 * @subpackage  com_contenthistory
 *
 * @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\Contenthistory\Api\Dispatcher;

use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Application\ApiApplication;
use Joomla\CMS\Dispatcher\ApiDispatcher;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
use Joomla\Registry\Registry;

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

/**
 * ComponentDispatcher class for com_contenthistory
 *
 * @since  5.4.11
 */
class Dispatcher extends ApiDispatcher
{
    /**
     * Method to check component access permission
     *
     * @since   5.4.11
     *
     * @return  void
     */
    protected function checkAccess(): void
    {
        $route = $this->app instanceof ApiApplication ? $this->app->getActiveRoute() : new Registry();
        $parts = FieldsHelper::extract($route->get('vars.type_alias'));

        // extract() returns null for a missing or invalid context
        if (empty($parts[0])) {
            throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
        }

        if ($this->app->getIdentity()->authorise('core.api', $parts[0])) {
            return;
        }

        throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
    }
}

No other release has this exact content. See every version of this file.