[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_associations/src/Dispatcher/ -> Dispatcher.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_associations
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Associations\Administrator\Dispatcher;
  12  
  13  use Joomla\CMS\Access\Exception\NotAllowed;
  14  use Joomla\CMS\Dispatcher\ComponentDispatcher;
  15  use Joomla\CMS\Language\Text;
  16  use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * ComponentDispatcher class for com_associations
  24   *
  25   * @since  4.0.0
  26   */
  27  class Dispatcher extends ComponentDispatcher
  28  {
  29      /**
  30       * Method to check component access permission
  31       *
  32       * @since   4.0.0
  33       *
  34       * @return  void
  35       *
  36       * @throws  \Exception|NotAllowed
  37       */
  38      protected function checkAccess()
  39      {
  40          parent::checkAccess();
  41  
  42          // Check if user has permission to access the component item type.
  43          $itemType = $this->input->get('itemtype', '', 'string');
  44  
  45          if ($itemType !== '') {
  46              list($extensionName, $typeName) = explode('.', $itemType);
  47  
  48              if (!AssociationsHelper::hasSupport($extensionName)) {
  49                  throw new \Exception(
  50                      Text::sprintf('COM_ASSOCIATIONS_COMPONENT_NOT_SUPPORTED', $this->app->getLanguage()->_($extensionName)),
  51                      404
  52                  );
  53              }
  54  
  55              if (!$this->app->getIdentity()->authorise('core.manage', $extensionName)) {
  56                  throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
  57              }
  58          }
  59      }
  60  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer