\Pho\Lib\Graph\EventEmitterTrait

Event Emitter Trait

This trait contains all the basic functions to implement an EventEmitterInterface.

Using the trait + interface allows you to add EventEmitter capabilities without having to change your base-class.

Please note, this is a slightly modified version of Sabre/Event to fit with Pho-Lib-Graph's needs.

Summary

Methods
Properties
Constants
on()
emit()
listeners()
removeAllListeners()
No public properties found
No constants found
No protected methods found
$listeners
$listeners_flat
N/A
No private methods found
No private properties found
N/A
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Properties

$listeners

$listeners : array

The list of listeners

Type

array

$listeners_flat

$listeners_flat : 

Type

Methods

on()

on(\Pho\Lib\Graph\Event\string  $eventName,   $callBack, \Pho\Lib\Graph\Event\int  $priority = 100) : void

Subscribe to an event.

Parameters

\Pho\Lib\Graph\Event\string $eventName
$callBack
\Pho\Lib\Graph\Event\int $priority
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

emit()

emit(\Pho\Lib\Graph\Event\string  $eventName, array  $arguments = array()) 

Emits an event.

This method will return true if 0 or more listeners were succesfully handled. false is returned if one of the events broke the event chain.

Pho: Please note, continueCallback does not exist with Pho

If the continueCallBack is specified, this callback will be called every time before the next event handler is called.

If the continueCallback returns false, event propagation stops. This allows you to use the eventEmitter as a means for listeners to implement functionality in your application, and break the event loop as soon as some condition is fulfilled.

Note that returning false from an event subscriber breaks propagation and returns false, but if the continue-callback stops propagation, this is still considered a 'successful' operation and returns true.

Lastly, if there are 5 event handlers for an event. The continueCallback will be called at most 4 times.

Parameters

\Pho\Lib\Graph\Event\string $eventName
array $arguments
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

listeners()

listeners(\Pho\Lib\Graph\Event\string  $eventName, \Pho\Lib\Graph\Event\bool  $flat = false) : array<mixed,callable>

Returns the list of listeners for an event.

The list is returned as an array, and the list of events are sorted by their priority.

Parameters

\Pho\Lib\Graph\Event\string $eventName
\Pho\Lib\Graph\Event\bool $flat
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array<mixed,callable>

removeAllListeners()

removeAllListeners(\Pho\Lib\Graph\Event\string  $eventName = null) : void

Removes all listeners.

If the eventName argument is specified, all listeners for that event are removed. If it is not specified, every listener for every event is removed.

Parameters

\Pho\Lib\Graph\Event\string $eventName
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275