[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Event/Table/ -> SetNewTagsEvent.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2016 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\Table;
  11  
  12  use BadMethodCallException;
  13  
  14  // phpcs:disable PSR1.Files.SideEffects
  15  \defined('JPATH_PLATFORM') or die;
  16  // phpcs:enable PSR1.Files.SideEffects
  17  
  18  /**
  19   * Event class for JTable's onSetNewTags event
  20   *
  21   * @since  4.0.0
  22   * @todo   Only used in JModelAdmin::batchTag since we can't use JTable::save as we don't want the data to be saved. Maybe trigger onBeforeStore?
  23   */
  24  class SetNewTagsEvent extends AbstractEvent
  25  {
  26      /**
  27       * Constructor.
  28       *
  29       * Mandatory arguments:
  30       * subject      JTableInterface The table we are operating on
  31       * newTags      int[]           New tags to be added to or replace current tags for an item
  32       * replaceTags  bool            Replace tags (true) or add them (false)
  33       *
  34       * @param   string  $name       The event name.
  35       * @param   array   $arguments  The event arguments.
  36       *
  37       * @throws  BadMethodCallException
  38       */
  39      public function __construct($name, array $arguments = array())
  40      {
  41          if (!\array_key_exists('newTags', $arguments)) {
  42              throw new BadMethodCallException("Argument 'newTags' is required for event $name");
  43          }
  44  
  45          if (!\array_key_exists('replaceTags', $arguments)) {
  46              throw new BadMethodCallException("Argument 'replaceTags' is required for event $name");
  47          }
  48  
  49          parent::__construct($name, $arguments);
  50      }
  51  
  52      /**
  53       * Setter for the replaceTags attribute
  54       *
  55       * @param   mixed  $value  The value to set
  56       *
  57       * @return  boolean  Normalised value
  58       */
  59      protected function setReplaceTags($value)
  60      {
  61          return $value ? true : false;
  62      }
  63  }


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