\Pho\Lib\GraphAttributeBag

Holds edge and node attributes

All graph entities may hold attributes. AttributeBag class is a common attribute of both edges and nodes.

$node = new Node();
$node->attributes()->color = "red";
if(isset($node->attributes()->color))
  echo $node->attributes()->color; // prints "red"
unset($this->attributes()->color);
echo $this->attributes()->color; // doesn't print

Summary

Methods
Properties
Constants
on()
emit()
listeners()
removeAllListeners()
__construct()
toArray()
quietSet()
No public properties found
No constants found
No protected methods found
$listeners
$listeners_flat
$bag
$owner
N/A
No private methods found
No private properties found
N/A

Properties

$listeners

$listeners : array

The list of listeners

Type

array

$listeners_flat

$listeners_flat : 

Type

$bag

$bag : array

Holds the attributes of a node in an array

Type

array

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

__construct()

__construct(\Pho\Lib\Graph\EntityInterface  $owner, array  $bag = array()) 

Constructor.

Parameter optional.

Parameters

\Pho\Lib\Graph\EntityInterface $owner
array $bag

Initial bag. Defaults to an empty array.

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

toArray()

toArray() : array

Retrieves the bag in array format

Useful for serialization/unserialization.

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 —

The object in pure array key/value pair form.

quietSet()

quietSet(string  $attribute, string|boolean|array  $value) : void

Silent setter

Sets a value without notifying the master object.

Parameters

string $attribute
string|boolean|array $value
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