- md5
- d55409bf258bddb229327eeef295b698
- sha1
- e4938d46fb21b142f0ec3b6691e764fa9c80621b
- sha256
- 7dbd7024031fe44ef065153d1c37d2c15b380eba6046fea1a0146d5dc76a2493
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Event;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* This class implements the immutable base Event object used system-wide to offer orthogonality.
*
* @see \Joomla\CMS\Event\AbstractEvent
* @since 4.0.0
*/
class AbstractImmutableEvent extends AbstractEvent
{
/**
* A flag to see if the constructor has been already called.
*
* @var boolean
* @since 4.0.0
*/
private $constructed = false;
/**
* Constructor.
*
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @since 4.0.0
* @throws BadMethodCallException
*/
public function __construct(string $name, array $arguments = [])
{
if ($this->constructed) {
throw new BadMethodCallException(
sprintf('Cannot reconstruct the AbstractImmutableEvent %s.', $this->name)
);
}
$this->constructed = true;
parent::__construct($name, $arguments);
}
/**
* Set the value of an event argument.
*
* @param string $name The argument name.
* @param mixed $value The argument value.
*
* @return void
*
* @since 4.0.0
* @throws BadMethodCallException
*/
public function offsetSet($name, $value)
{
throw new BadMethodCallException(
sprintf(
'Cannot set the argument %s of the immutable event %s.',
$name,
$this->name
)
);
}
/**
* Remove an event argument.
*
* @param string $name The argument name.
*
* @return void
*
* @since 4.0.0
* @throws BadMethodCallException
*/
public function offsetUnset($name)
{
throw new BadMethodCallException(
sprintf(
'Cannot remove the argument %s of the immutable event %s.',
$name,
$this->name
)
);
}
}
The same content is in 8 releases, Joomla 4.3.2-rc1 to 4.4.0-alpha2. See them all, or every version of this file.