[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Event/QuickIcon/ -> GetIconEvent.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license        GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  namespace Joomla\CMS\Event\QuickIcon;
  11  
  12  use BadMethodCallException;
  13  use DomainException;
  14  use Joomla\CMS\Event\AbstractImmutableEvent;
  15  use Joomla\CMS\Event\ReshapeArgumentsAware;
  16  use Joomla\CMS\Event\Result\ResultAware;
  17  use Joomla\CMS\Event\Result\ResultAwareInterface;
  18  use Joomla\CMS\Event\Result\ResultTypeArrayAware;
  19  
  20  // phpcs:disable PSR1.Files.SideEffects
  21  \defined('JPATH_PLATFORM') or die;
  22  // phpcs:enable PSR1.Files.SideEffects
  23  
  24  /**
  25   * Event class for the onGetIcon event.
  26   *
  27   * @since  4.2.0
  28   */
  29  class GetIconEvent extends AbstractImmutableEvent implements ResultAwareInterface
  30  {
  31      use ResultAware;
  32      use ResultTypeArrayAware;
  33      use ReshapeArgumentsAware;
  34  
  35      /**
  36       * Constructor.
  37       *
  38       * @param   string  $name       The event name.
  39       * @param   array   $arguments  The event arguments.
  40       *
  41       * @since   4.2.0
  42       * @throws  BadMethodCallException
  43       */
  44      public function __construct(string $name, array $arguments = [])
  45      {
  46          $this->reshapeArguments($arguments, ['context']);
  47  
  48          parent::__construct($name, $arguments);
  49      }
  50  
  51      /**
  52       * A method to validate the 'context' named parameter.
  53       *
  54       * @param   string  $value  The calling context for retrieving icons.
  55       *
  56       * @return  void
  57       *
  58       * @since   4.2.0
  59       */
  60      public function setContext(string $value)
  61      {
  62          if (empty($value)) {
  63              throw new DomainException(sprintf("Argument 'context' of event %s must be a non-empty string.", $this->name));
  64          }
  65      }
  66  }


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