class Event

Event listener.

Properties

protected Container $container Container.
protected array $events Registered event listeners.

Methods

__construct(Container|null $container = null)

Constructor.

register(string $name, string|Closure $handler)

Registers an event handler.

bool
has(string $name)

Returns TRUE if an event listener is registered for the event and FALSE if not.

array
events()

Returns an array of all registered events.

clear(string $name)

Clears all events handlers for the specified event.

override(string $name, string|Closure $handler)

Overrides an event.

mixed
executeClosureHandler(Closure $handler, array $parameters)

Executes a closure handler and returns the response.

resolveHandler(string $handler)

Resolves a class handler.

mixed
executeClassHandler(EventHandlerInterface $handler, array $parameters)

Executes a class handler and returns the response.

mixed
executeHandler(string|Closure $handler, array $parameters)

Executes the event handler and returns the response.

array
trigger(string $name, array $parameters = [], bool $break = false)

Runs all closures for an event and returns an array contaning the return values of each event handler.

Details

at line 41
__construct(Container|null $container = null)

Constructor.

Parameters

Container|null $container Container

at line 52
register(string $name, string|Closure $handler)

Registers an event handler.

Parameters

string $name Event name
string|Closure $handler Event handler

at line 63
bool has(string $name)

Returns TRUE if an event listener is registered for the event and FALSE if not.

Parameters

string $name Event name

Return Value

bool

at line 73
array events()

Returns an array of all registered events.

Return Value

array

at line 83
clear(string $name)

Clears all events handlers for the specified event.

Parameters

string $name Event name

at line 94
override(string $name, string|Closure $handler)

Overrides an event.

Parameters

string $name Event name
string|Closure $handler Event handler

at line 108
protected mixed executeClosureHandler(Closure $handler, array $parameters)

Executes a closure handler and returns the response.

Parameters

Closure $handler Event handler
array $parameters Parameters

Return Value

mixed

at line 119
protected EventHandlerInterface resolveHandler(string $handler)

Resolves a class handler.

Parameters

string $handler Event handler class

Return Value

EventHandlerInterface

at line 131
protected mixed executeClassHandler(EventHandlerInterface $handler, array $parameters)

Executes a class handler and returns the response.

Parameters

EventHandlerInterface $handler Event handler
array $parameters Parameters

Return Value

mixed

at line 143
protected mixed executeHandler(string|Closure $handler, array $parameters)

Executes the event handler and returns the response.

Parameters

string|Closure $handler Event handler
array $parameters Parameters

Return Value

mixed

at line 164
array trigger(string $name, array $parameters = [], bool $break = false)

Runs all closures for an event and returns an array contaning the return values of each event handler.

Parameters

string $name Event name
array $parameters Parameters
bool $break Break if one of the closures returns false?

Return Value

array