[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2020 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\Component\Content\Administrator\Event\Model; 11 12 use BadMethodCallException; 13 use Joomla\CMS\Event\AbstractImmutableEvent; 14 15 // phpcs:disable PSR1.Files.SideEffects 16 \defined('JPATH_PLATFORM') or die; 17 // phpcs:enable PSR1.Files.SideEffects 18 19 /** 20 * Event class for WebAsset events 21 * 22 * @since 4.0.0 23 */ 24 class FeatureEvent extends AbstractImmutableEvent 25 { 26 /** 27 * Constructor. 28 * 29 * @param string $name The event name. 30 * @param array $arguments The event arguments. 31 * 32 * @throws BadMethodCallException 33 * 34 * @since 4.0.0 35 */ 36 public function __construct($name, array $arguments = array()) 37 { 38 if (!isset($arguments['extension'])) { 39 throw new BadMethodCallException("Argument 'extension' of event $this->name is required but has not been provided"); 40 } 41 42 if (!isset($arguments['extension']) || !is_string($arguments['extension'])) { 43 throw new BadMethodCallException("Argument 'extension' of event $this->name is not of type 'string'"); 44 } 45 46 if (strpos($arguments['extension'], '.') === false) { 47 throw new BadMethodCallException("Argument 'extension' of event $this->name has wrong format. Valid format: 'component.section'"); 48 } 49 50 if (!\array_key_exists('extensionName', $arguments) || !\array_key_exists('section', $arguments)) { 51 $parts = explode('.', $arguments['extension']); 52 53 $arguments['extensionName'] = $arguments['extensionName'] ?? $parts[0]; 54 $arguments['section'] = $arguments['section'] ?? $parts[1]; 55 } 56 57 if (!isset($arguments['pks']) || !is_array($arguments['pks'])) { 58 throw new BadMethodCallException("Argument 'pks' of event $this->name is not of type 'array'"); 59 } 60 61 if (!isset($arguments['value']) || !is_numeric($arguments['value'])) { 62 throw new BadMethodCallException("Argument 'value' of event $this->name is not of type 'numeric'"); 63 } 64 65 $arguments['value'] = (int) $arguments['value']; 66 67 if ($arguments['value'] !== 0 && $arguments['value'] !== 1) { 68 throw new BadMethodCallException("Argument 'value' of event $this->name is not 0 or 1"); 69 } 70 71 parent::__construct($name, $arguments); 72 } 73 74 /** 75 * Set used parameter to true 76 * 77 * @param bool $value The value to set 78 * 79 * @return void 80 * 81 * @since 4.0.0 82 */ 83 public function setAbort(string $reason) 84 { 85 $this->arguments['abort'] = true; 86 $this->arguments['abortReason'] = $reason; 87 } 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |