src/Sulu/Bundle/AdminBundle/Navigation/NavigationItem.php
public function merge(self $other = null)
    {
        // Create new item
        $new = $this->copyChildless();

        // Add all children from this item
        foreach ($this->getChildren() as $child) {
            /* @var NavigationItem $child */
            $new->addChild($child->merge((null != $other) ? $other->findChildren($child) : null));
        }

        // Add all children from the other item
        if (null != $other) {
            foreach ($other->getChildren() as $child) {
                /** @var NavigationItem $child */
                if (!$new->find($child)) {
                    $new->addChild($child->merge($this->copyChildless()));
                }
            }
        }

        return $new;
    }
public function merge(self $other = null)
    {
        // Create new item
        $new = $this->copyChildless();

        // Add all children from this item
        foreach ($this->getChildren() as $child) {
            /* @var NavigationItem $child */
            $new->addChild($child->merge((null != $other) ? $other->findChildren($child) : null));
        }

        // Add all children from the other item
        if (null != $other) {
            foreach ($other->getChildren() as $child) {
                /** @var NavigationItem $child */
                if (!$new->find($child)) {
                    $new->addChild($child->merge($this->copyChildless()));
                }
            }
        }

        return $new;
    }
public function merge ( self $ other = null ) { // Create new item $ new = $ this -> copyChildless ( ) ; // Add all children from this item foreach ( $ this -> getChildren ( ) as $ child ) { /* @var NavigationItem $child */ $ new -> addChild ( $ child -> merge ( ( null != $ other ) ? $ other -> findChildren ( $ child ) : null ) ) ; } // Add all children from the other item if ( null != $ other ) { foreach ( $ other -> getChildren ( ) as $ child ) { /** @var NavigationItem $child */ if ( ! $ new -> find ( $ child ) ) { $ new -> addChild ( $ child -> merge ( $ this -> copyChildless ( ) ) ) ; } } } return $ new ; }
Merges this navigation item with the other parameter and returns a new NavigationItem.
Works only if there are no duplicate values on one level.

@param NavigationItem $other The navigation item this one should be merged with

@return NavigationItem
Merges this navigation item with the other parameter and returns a new NavigationItem . Works only if there are no duplicate values on one level .