src/Node/Node.php
public function handleEvent(string $eventId, array $eventData)
    {
        switch ($eventId) {
            case self::EVENT_ADD_CHILD:
                /** @var NodeInterface $node */
                $node = $eventData['child'];

                $this->addNode($node);

                break;
            case self::EVENT_REMOVE_CHILD:
                /** @var NodeInterface $node */
                $node = $eventData['child'];

                $this->removeNode($node);

                break;
            case self::EVENT_ADD_PARENT:
                /** @var NodeInterface $child */
                $child = $eventData['child'];
                /** @var NodeInterface $newParent */
                $newParent = $eventData['newParent'];
                $nodes = $child->getNodes() + [$child];

                /** @var NodeInterface $n */
                foreach ($nodes as $n) {
                    $n->addSubscriber($newParent);
                    $newParent->addNode($n);
                }

                break;
            case self::EVENT_REMOVE_PARENT:
                /** @var NodeInterface $child */
                $child = $eventData['child'];
                /** @var NodeInterface $oldParent */
                $oldParent = $eventData['parentToRemove'];
                $nodes = $child->getNodes() + [$child];

                /** @var NodeInterface $n */
                foreach ($nodes as $n) {
                    $n->removeSubscriber($oldParent);
                    $oldParent->removeNode($n);
                }

                break;
            default:
                break;
        }
    }
public function handleEvent(string $eventId, array $eventData)
    {
        switch ($eventId) {
            case self::EVENT_ADD_CHILD:
                /** @var NodeInterface $node */
                $node = $eventData['child'];

                $this->addNode($node);

                break;
            case self::EVENT_REMOVE_CHILD:
                /** @var NodeInterface $node */
                $node = $eventData['child'];

                $this->removeNode($node);

                break;
            case self::EVENT_ADD_PARENT:
                /** @var NodeInterface $child */
                $child = $eventData['child'];
                /** @var NodeInterface $newParent */
                $newParent = $eventData['newParent'];
                $nodes = $child->getNodes() + [$child];

                /** @var NodeInterface $n */
                foreach ($nodes as $n) {
                    $n->addSubscriber($newParent);
                    $newParent->addNode($n);
                }

                break;
            case self::EVENT_REMOVE_PARENT:
                /** @var NodeInterface $child */
                $child = $eventData['child'];
                /** @var NodeInterface $oldParent */
                $oldParent = $eventData['parentToRemove'];
                $nodes = $child->getNodes() + [$child];

                /** @var NodeInterface $n */
                foreach ($nodes as $n) {
                    $n->removeSubscriber($oldParent);
                    $oldParent->removeNode($n);
                }

                break;
            default:
                break;
        }
    }
public function handleEvent ( string $ eventId , array $ eventData ) { switch ( $ eventId ) { case self :: EVENT_ADD_CHILD : /** @var NodeInterface $node */ $ node = $ eventData [ 'child' ] ; $ this -> addNode ( $ node ) ; break ; case self :: EVENT_REMOVE_CHILD : /** @var NodeInterface $node */ $ node = $ eventData [ 'child' ] ; $ this -> removeNode ( $ node ) ; break ; case self :: EVENT_ADD_PARENT : /** @var NodeInterface $child */ $ child = $ eventData [ 'child' ] ; /** @var NodeInterface $newParent */ $ newParent = $ eventData [ 'newParent' ] ; $ nodes = $ child -> getNodes ( ) + [ $ child ] ; /** @var NodeInterface $n */ foreach ( $ nodes as $ n ) { $ n -> addSubscriber ( $ newParent ) ; $ newParent -> addNode ( $ n ) ; } break ; case self :: EVENT_REMOVE_PARENT : /** @var NodeInterface $child */ $ child = $ eventData [ 'child' ] ; /** @var NodeInterface $oldParent */ $ oldParent = $ eventData [ 'parentToRemove' ] ; $ nodes = $ child -> getNodes ( ) + [ $ child ] ; /** @var NodeInterface $n */ foreach ( $ nodes as $ n ) { $ n -> removeSubscriber ( $ oldParent ) ; $ oldParent -> removeNode ( $ n ) ; } break ; default : break ; } }
This method is called when an event is fired.

@param string $eventId   - Event ID.
@param array  $eventData - Event Data.

@return void
This method is called when an event is fired .