CoreFiles by mySites.guru
Dispatcher.php53 lines, 1,500 bytes, from Joomla_6.3.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 6.2.0-alpha3
md5
b902c44796363ab604a362a8a18d0274
sha1
254d9975a969296b6ef8b735b16b5794c4bf511b
sha256
72ef111afa6c9b82a16371267890120ca061217e84c2dfdda763e11c4bfa0152
<?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  6.2.1
 */
class Dispatcher extends ApiDispatcher
{
    /**
     * Method to check component access permission
     *
     * @since   6.2.1
     *
     * @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);
    }
}

The same content is in 2 releases, Joomla 6.2.1 to 6.3.0-alpha1. See them all, or every version of this file.