[ 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) 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; 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 * This class implements the immutable base Event object used system-wide to offer orthogonality. 20 * 21 * @see \Joomla\CMS\Event\AbstractEvent 22 * @since 4.0.0 23 */ 24 class AbstractImmutableEvent extends AbstractEvent 25 { 26 /** 27 * A flag to see if the constructor has been already called. 28 * 29 * @var boolean 30 * @since 4.0.0 31 */ 32 private $constructed = false; 33 34 /** 35 * Constructor. 36 * 37 * @param string $name The event name. 38 * @param array $arguments The event arguments. 39 * 40 * @since 4.0.0 41 * @throws BadMethodCallException 42 */ 43 public function __construct(string $name, array $arguments = []) 44 { 45 if ($this->constructed) { 46 throw new BadMethodCallException( 47 sprintf('Cannot reconstruct the AbstractImmutableEvent %s.', $this->name) 48 ); 49 } 50 51 $this->constructed = true; 52 53 parent::__construct($name, $arguments); 54 } 55 56 /** 57 * Set the value of an event argument. 58 * 59 * @param string $name The argument name. 60 * @param mixed $value The argument value. 61 * 62 * @return void 63 * 64 * @since 4.0.0 65 * @throws BadMethodCallException 66 */ 67 public function offsetSet($name, $value) 68 { 69 throw new BadMethodCallException( 70 sprintf( 71 'Cannot set the argument %s of the immutable event %s.', 72 $name, 73 $this->name 74 ) 75 ); 76 } 77 78 /** 79 * Remove an event argument. 80 * 81 * @param string $name The argument name. 82 * 83 * @return void 84 * 85 * @since 4.0.0 86 * @throws BadMethodCallException 87 */ 88 public function offsetUnset($name) 89 { 90 throw new BadMethodCallException( 91 sprintf( 92 'Cannot remove the argument %s of the immutable event %s.', 93 $name, 94 $this->name 95 ) 96 ); 97 } 98 }
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 |