Class: EventManager

Class for event management.

Implements

Authors

Oleg Schildt

Package

Source code

 

Properties
static protected

Internal array for storing the event handler mappings.

static protected

Internal array for storing the suspended events.

Methods
public

Adds the handler of an event.

public

Deletes all handlers of all events.

public

Deletes the handler of an event.

public

Deletes all handlers of an event.

public

Fires and event.

public

Resumes all previously suspended events.

public

Resumes a previously suspended event.

public

Suspends an event.


Property: EventManager::$event_table

protected static array $event_table = [];

Internal array for storing the event handler mappings.

Type

array

Authors

Oleg Schildt

Source code

See also


Property: EventManager::$suspended_events

protected static array $suspended_events = [];

Internal array for storing the suspended events.

Type

array

Authors

Oleg Schildt

Source code

See also


Method: EventManager::addHandler()

public function addHandler(string $event, callable $handler): void;

Adds the handler of an event.

Parameters

Name Pass type Value type Default value Description
$event by value string

Event code.

$handler by value callable

The name or definition of the handler function. The signature of this function is:

function (string $event, array $parameters) : void;
  • $event - the event code.

  • $parameters - parameters passed by the firing of the event.

Returns

void

Throws

\Exception

It might throw the following exceptions in the case of any errors:

  • if the event name is not specified.
  • if the event handler is not valid.
  • if the creation of the handler fails.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: EventManager::deleteAllHandlers()

public function deleteAllHandlers(): void;

Deletes all handlers of all events.

Returns

void

Returns true if the deletion was successful, otherwise false.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: EventManager::deleteHandler()

public function deleteHandler(string $event, callable $handler): void;

Deletes the handler of an event.

Parameters

Name Pass type Value type Default value Description
$event by value string

Event code.

$handler by value callable

The name or definition of the handler function.

Returns

void

Throws

\Exception

It might throw the following exceptions in the case of any errors:

  • if the event name is not specified.
  • if the event handler is not valid.
  • if the creation of the handler fails.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: EventManager::deleteHandlers()

public function deleteHandlers(string $event): void;

Deletes all handlers of an event.

Parameters

Name Pass type Value type Default value Description
$event by value string

Event code.

Returns

void

Throws

\Exception

It might throw the following exceptions in the case of any errors:

  • if the event name is not specified.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: EventManager::fireEvent()

public function fireEvent(string $event, array $parameters): int;

Fires and event.

Parameters

Name Pass type Value type Default value Description
$event by value string

Event code.

$parameters by value array

Event code.

Returns

int

Returns number of the handlers called for this event.

Throws

\Exception

It might throw the following exceptions in the case of any errors:

  • if the event name is not specified.
  • if the creation of the handler fails.

Overrides

Authors

Oleg Schildt

Source code


Method: EventManager::resumeAllEvents()

public function resumeAllEvents(): void;

Resumes all previously suspended events.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: EventManager::resumeEvent()

public function resumeEvent(string $event): void;

Resumes a previously suspended event.

Parameters

Name Pass type Value type Default value Description
$event by value string

Event code.

Returns

void

Throws

\Exception

It might throw the following exceptions in the case of any errors:

  • if the event name is not specified.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: EventManager::suspendEvent()

public function suspendEvent(string $event): void;

Suspends an event.

Details

If an event is suspended, its handlers are not called when the event is fired.

Parameters

Name Pass type Value type Default value Description
$event by value string

Event code.

Returns

void

Throws

\Exception

It might throw the following exceptions in the case of any errors:

  • if the event name is not specified.

Overrides

Authors

Oleg Schildt

Source code

See also