CoreFiles by mySites.guru
Dispatcher.php53 lines, 1,475 bytes, from Joomla_5.4.11-Stable-Full_Package.zip
Raw History Compare with 5.4.10
md5
376ddeb3f1cc809be87b6747c1601156
sha1
c3cd2c395572b6cc370064eea9de007d32551c6a
sha256
6b074d8d8725c48d28035456a5644a0772bda58466916831ac5e353c93b08910
<?php

/**
 * @package     Joomla.Api
 * @subpackage  com_fields
 *
 * @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\Fields\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_fields
 *
 * @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.context'));

        // 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.