Class Event
arrayCustom data for the method that receives the event
stringName of the event
boolFlags an event as stopped or not, default is false
object|nullThe object this event applies to (usually the same object that generates the event)
mixedProperty used to retain the result value of the event listeners
Constructor
Access the event data/payload.
Returns the name of this event. This is usually used as the event identifier
The result value of the event listeners
Returns the subject of this event
Check if the event is stopped
Assigns a value to the data/payload of this event.
Listeners can attach a result value to the event.
Stops the event from being used anymore
__construct(string $name, object|null $subject = null, ArrayAccess|array|null $data = null)
Constructor
$event = new Event('Order.afterBuy', $this, ['buyer' => $userData]);
$event = new Event('User.afterRegister', $userModel); string $name Name of the event
object|null $subject optional the object that this event applies to (usually the object that is generating the event).
ArrayAccess|array|null $data optional any value you wish to be transported with this event to it can be read by listeners.
getData(string|null $key = null): mixed|array|null
Access the event data/payload.
string|null $key optional The data payload element to return, or null to return all data.
mixed|array|nullgetName(): string
Returns the name of this event. This is usually used as the event identifier
stringgetResult(): mixed
The result value of the event listeners
mixedgetSubject(): object
Returns the subject of this event
If the event has no subject an exception will be raised.
objectCake\Core\Exception\CakeExceptionisStopped(): bool
Check if the event is stopped
boolsetData(array|string $key, mixed $value = null): $this
Assigns a value to the data/payload of this event.
array|string $key An array will replace all payload data, and a key will set just that array item.
mixed $value optional The value to set.
$thissetResult(mixed $value = null): $this
Listeners can attach a result value to the event.
mixed $value optional The value to set.
$thisstopPropagation(): void
Stops the event from being used anymore
voidCustom data for the method that receives the event
arrayName of the event
stringFlags an event as stopped or not, default is false
boolThe object this event applies to (usually the same object that generates the event)
object|nullProperty used to retain the result value of the event listeners
Use setResult() and getResult() to set and get the result.
mixed
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Event.Event.html