Documentation

GenericEvent extends Event
in package
implements ArrayAccess, IteratorAggregate

Event encapsulation class.

Encapsulates events thus decoupling the observer from the subject they encapsulate.

Tags
author

Drak drak@zikula.org

Table of Contents

Interfaces

ArrayAccess
IteratorAggregate

Properties

$arguments  : array<string|int, mixed>
Array of arguments.
$subject  : mixed
Event subject.
$dispatcher  : EventDispatcher
$name  : string
$propagationStopped  : bool

Methods

__construct()  : mixed
Encapsulate an event with $subject and $args.
getArgument()  : mixed
Get argument by key.
getArguments()  : array<string|int, mixed>
Getter for all arguments.
getDispatcher()  : EventDispatcherInterface
Returns the EventDispatcher that dispatches this Event.
getIterator()  : ArrayIterator
IteratorAggregate for iterating over the object like an array.
getName()  : string
Gets the event's name.
getSubject()  : mixed
Getter for subject property.
hasArgument()  : bool
Has argument.
isPropagationStopped()  : bool
Returns whether further event listeners should be triggered.
offsetExists()  : bool
ArrayAccess has argument.
offsetGet()  : mixed
ArrayAccess for argument getter.
offsetSet()  : mixed
ArrayAccess for argument setter.
offsetUnset()  : mixed
ArrayAccess for unset argument.
setArgument()  : GenericEvent
Add argument to event.
setArguments()  : GenericEvent
Set args property.
setDispatcher()  : mixed
Stores the EventDispatcher that dispatches this Event.
setName()  : mixed
Sets the event's name property.
stopPropagation()  : mixed
Stops the propagation of the event to further event listeners.

Properties

$arguments

Array of arguments.

protected array<string|int, mixed> $arguments

$subject

Event subject.

protected mixed $subject

usually object or callable

$name

private string $name

This event's name

$propagationStopped

private bool $propagationStopped = false

Whether no further event listeners should be triggered

Methods

__construct()

Encapsulate an event with $subject and $args.

public __construct([mixed $subject = null ][, array<string|int, mixed> $arguments = array() ]) : mixed
Parameters
$subject : mixed = null

The subject of the event, usually an object.

$arguments : array<string|int, mixed> = array()

Arguments to store in the event.

getArgument()

Get argument by key.

public getArgument(string $key) : mixed
Parameters
$key : string

Key.

Tags
throws
InvalidArgumentException

If key is not found.

Return values
mixed

Contents of array key.

getArguments()

Getter for all arguments.

public getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>

getIterator()

IteratorAggregate for iterating over the object like an array.

public getIterator() : ArrayIterator
Return values
ArrayIterator

getName()

Gets the event's name.

public getName() : string

since version 2.4, to be removed in 3.0. The event name is passed to the listener call.

Return values
string

getSubject()

Getter for subject property.

public getSubject() : mixed
Return values
mixed

$subject The observer subject.

hasArgument()

Has argument.

public hasArgument(string $key) : bool
Parameters
$key : string

Key of arguments array.

Return values
bool

isPropagationStopped()

Returns whether further event listeners should be triggered.

public isPropagationStopped() : bool
Tags
see
Event::stopPropagation()
Return values
bool

Whether propagation was already stopped for this event.

offsetExists()

ArrayAccess has argument.

public offsetExists(string $key) : bool
Parameters
$key : string

Array key.

Return values
bool

offsetGet()

ArrayAccess for argument getter.

public offsetGet(string $key) : mixed
Parameters
$key : string

Array key.

Tags
throws
InvalidArgumentException

If key does not exist in $this->args.

offsetSet()

ArrayAccess for argument setter.

public offsetSet(string $key, mixed $value) : mixed
Parameters
$key : string

Array key to set.

$value : mixed

Value.

offsetUnset()

ArrayAccess for unset argument.

public offsetUnset(string $key) : mixed
Parameters
$key : string

Array key.

setArgument()

Add argument to event.

public setArgument(string $key, mixed $value) : GenericEvent
Parameters
$key : string

Argument name.

$value : mixed

Value.

Return values
GenericEvent

setArguments()

Set args property.

public setArguments([array<string|int, mixed> $args = array() ]) : GenericEvent
Parameters
$args : array<string|int, mixed> = array()

Arguments.

Return values
GenericEvent

setDispatcher()

Stores the EventDispatcher that dispatches this Event.

public setDispatcher(EventDispatcherInterface $dispatcher) : mixed

since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.

Parameters
$dispatcher : EventDispatcherInterface

setName()

Sets the event's name property.

public setName(string $name) : mixed

since version 2.4, to be removed in 3.0. The event name is passed to the listener call.

Parameters
$name : string

The event name.

stopPropagation()

Stops the propagation of the event to further event listeners.

public stopPropagation() : mixed

If multiple event listeners are connected to the same event, no further event listener will be triggered once any trigger calls stopPropagation().


        
On this page

Search results