Documentation

EventManager extends Emitter
in package

Class EventManager.

Register handler, send event.

Tags
author

MacFJA

license

MIT

Table of Contents

Constants

SIGNAL_COMP_COMPILATION  = 'compilation'
Indicate that the Unix Signal is not supported because PHP has not been compiled with signal support
SIGNAL_COMP_OK  = 'ok'
Indicate that the Unix Signal is supported by the system and PHP
SIGNAL_COMP_WINDOWS  = 'windows'
Indicate that the Unix Signal is not supported because we are on a Windows System

Properties

$application  : Application
The current Phar-Builder application
$listeners  : array<string|int, mixed>
The registered listeners.
$sortedListeners  : array<string|int, ListenerInterface>
The sorted listeners

Methods

__construct()  : mixed
EventManager constructor.
addListener()  : $this
Add a listener for an event.
addOneTimeListener()  : $this
Add a one time listener for an event.
emit()  : EventInterface
Emit an event.
emitBatch()  : array<string|int, mixed>
Emit a batch of events.
emitGeneratedEvents()  : array<string|int, EventInterface>
Release all events stored in a generator
getListeners()  : array<string|int, mixed>
Get all the listeners for an event.
hasListeners()  : bool
Check whether an event has listeners.
isSignalCompatible()  : string
Check is the current system and PHP support UNIX signal
registerApplication()  : void
Register the application event handler and the Unix signal handler
removeAllListeners()  : $this
Remove all listeners for an event.
removeListener()  : $this
Remove a specific listener for an event.
unixSignalHandler()  : void
The Unix signal handler. (Re-send to the application event handler)
useListenerProvider()  : $this
Use a provider to add listeners.
clearSortedListeners()  : mixed
Clear the sorted listeners for an event
ensureEvent()  : EventInterface
Ensure event input is of type EventInterface or convert it.
ensureListener()  : ListenerInterface
Ensure the input is a listener.
getSortedListeners()  : array<string|int, ListenerInterface>
Get the listeners sorted by priority for a given event.
invokeListeners()  : void
Invoke the listeners for an event.
prepareEvent()  : array<string|int, mixed>
Prepare an event for emitting.

Constants

SIGNAL_COMP_COMPILATION

Indicate that the Unix Signal is not supported because PHP has not been compiled with signal support

public mixed SIGNAL_COMP_COMPILATION = 'compilation'

SIGNAL_COMP_OK

Indicate that the Unix Signal is supported by the system and PHP

public mixed SIGNAL_COMP_OK = 'ok'

SIGNAL_COMP_WINDOWS

Indicate that the Unix Signal is not supported because we are on a Windows System

public mixed SIGNAL_COMP_WINDOWS = 'windows'

Properties

$listeners

The registered listeners.

protected array<string|int, mixed> $listeners = []

$sortedListeners

The sorted listeners

protected array<string|int, ListenerInterface> $sortedListeners = []

Listeners will get sorted and stored for re-use.

Methods

addListener()

Add a listener for an event.

public addListener(mixed $event, mixed $listener[, mixed $priority = self::P_NORMAL ]) : $this
Parameters
$event : mixed
$listener : mixed
$priority : mixed = self::P_NORMAL
Tags
inheritdoc
Return values
$this

addOneTimeListener()

Add a one time listener for an event.

public addOneTimeListener(mixed $event, mixed $listener[, mixed $priority = self::P_NORMAL ]) : $this
Parameters
$event : mixed
$listener : mixed
$priority : mixed = self::P_NORMAL
Tags
inheritdoc
Return values
$this

emitBatch()

Emit a batch of events.

public emitBatch(array<string|int, mixed> $events) : array<string|int, mixed>
Parameters
$events : array<string|int, mixed>
Tags
inheritdoc
Return values
array<string|int, mixed>

getListeners()

Get all the listeners for an event.

public getListeners(mixed $event) : array<string|int, mixed>
Parameters
$event : mixed
Tags
inheritdoc
Return values
array<string|int, mixed>

hasListeners()

Check whether an event has listeners.

public hasListeners(mixed $event) : bool
Parameters
$event : mixed
Tags
inheritdoc
Return values
bool

isSignalCompatible()

Check is the current system and PHP support UNIX signal

public isSignalCompatible() : string
Return values
string

registerApplication()

Register the application event handler and the Unix signal handler

public registerApplication() : void

removeAllListeners()

Remove all listeners for an event.

public removeAllListeners(mixed $event) : $this
Parameters
$event : mixed
Tags
inheritdoc
Return values
$this

removeListener()

Remove a specific listener for an event.

public removeListener(mixed $event, mixed $listener) : $this
Parameters
$event : mixed
$listener : mixed
Tags
inheritdoc
Return values
$this

unixSignalHandler()

The Unix signal handler. (Re-send to the application event handler)

public unixSignalHandler(int $signal) : void
Parameters
$signal : int

The Unix signal code

Tags
SuppressWarnings

(PHPMD.ExitExpression) -- Normal/Wanted behavior

clearSortedListeners()

Clear the sorted listeners for an event

protected clearSortedListeners(mixed $event) : mixed
Parameters
$event : mixed

getSortedListeners()

Get the listeners sorted by priority for a given event.

protected getSortedListeners(string $event) : array<string|int, ListenerInterface>
Parameters
$event : string
Return values
array<string|int, ListenerInterface>

invokeListeners()

Invoke the listeners for an event.

protected invokeListeners(string $name, EventInterface $event, array<string|int, mixed> $arguments) : void
Parameters
$name : string
$event : EventInterface
$arguments : array<string|int, mixed>

prepareEvent()

Prepare an event for emitting.

protected prepareEvent(string|EventInterface $event) : array<string|int, mixed>
Parameters
$event : string|EventInterface
Return values
array<string|int, mixed>

        
On this page

Search results