Class ClientEvent
Class Client Event
Property Summary
-
$_data protected
array
Custom data for the method that receives the event
-
$_name protected
string
Name of the event
-
$_stopped protected
bool
Flags an event as stopped or not, default is false
-
$_subject protected
object|null
The object this event applies to (usually the same object that generates the event)
-
$result protected
mixed
Property used to retain the result value of the event listeners
Method Summary
-
__construct() public
Constructor
-
getAdapterOptions() public
Get the adapter options.
-
getData() public
Accesses the event data/payload.
-
getName() public
Returns the name of this event. This is usually used as the event identifier
-
getRequest() public
Get the request instance.
-
getResult() public
The result value of the event listeners
-
getSubject() public
Returns the subject of this event
-
isStopped() public
Check if the event is stopped
-
setAdapterOptions() public
Set the adapter options.
-
setData() public
Assigns a value to the data/payload of this event.
-
setRequest() public
Set request instance.
-
setResult() public
Listeners can attach a result value to the event.
-
stopPropagation() public
Stops the event from being used anymore
Method Detail
__construct() ¶ public
__construct(string $name, Cake\Http\Client $subject, array $data = [])
Constructor
Examples of usage:
$event = new Event('Order.afterBuy', $this, ['buyer' => $userData]);
$event = new Event('User.afterRegister', $userModel);
Parameters
-
string
$name Name of the event
-
Cake\Http\Client
$subject The Http Client instance this event applies to.
-
array
$data optional Any value you wish to be transported with this event to it can be read by listeners.
getData() ¶ public
getData(string|null $key = null): mixed
Accesses the event data/payload.
Parameters
-
string|null
$key optional
Returns
mixed
getName() ¶ public
getName(): string
Returns the name of this event. This is usually used as the event identifier
Returns
string
getRequest() ¶ public
getRequest(): Psr\Http\Message\RequestInterface
Get the request instance.
Returns
Psr\Http\Message\RequestInterface
getResult() ¶ public
getResult(): Cake\Http\Client\Response|null
The result value of the event listeners
Returns
Cake\Http\Client\Response|null
getSubject() ¶ public
getSubject(): object
Returns the subject of this event
If the event has no subject an exception will be raised.
Returns
object
Throws
Cake\Core\Exception\CakeException
setAdapterOptions() ¶ public
setAdapterOptions(array $options = []): $this
Set the adapter options.
Parameters
-
array
$options optional
Returns
$this
setData() ¶ public
setData(array|string $key, mixed $value = null): $this
Assigns a value to the data/payload of this event.
Parameters
-
array|string
$key -
mixed
$value optional
Returns
$this
setRequest() ¶ public
setRequest(Psr\Http\Message\RequestInterface $request): $this
Set request instance.
Parameters
-
Psr\Http\Message\RequestInterface
$request
Returns
$this
setResult() ¶ public
setResult(mixed $value = null): $this
Listeners can attach a result value to the event.
Parameters
-
mixed
$value optional The value to set.
Returns
$this
stopPropagation() ¶ public
stopPropagation(): void
Stops the event from being used anymore
Returns
void