src/Sulu/Bundle/AdminBundle/Navigation/NavigationItem.php
public function toArray()
    {
        $array = [
            'title' => $this->getName(),
            'label' => $this->getLabel(),
            'icon' => $this->getIcon(),
            'action' => $this->getAction(),
            'mainRoute' => $this->getMainRoute(),
            'event' => $this->getEvent(),
            'eventArguments' => $this->getEventArguments(),
            'hasSettings' => $this->getHasSettings(),
            'disabled' => $this->getDisabled(),
            'id' => (null != $this->getId()) ? $this->getId() : str_replace('.', '', uniqid('', true)), //FIXME don't use uniqid()
        ];

        if (count($this->getChildRoutes()) > 0) {
            $array['childRoutes'] = $this->getChildRoutes();
        }

        if (null != $this->getHeaderIcon() || null != $this->getHeaderTitle()) {
            $array['header'] = [
                'title' => $this->getHeaderTitle(),
                'logo' => $this->getHeaderIcon(),
            ];
        }

        $children = $this->getChildren();

        usort(
            $children,
            function(NavigationItem $a, NavigationItem $b) {
                $aPosition = $a->getPosition() ?: PHP_INT_MAX;
                $bPosition = $b->getPosition() ?: PHP_INT_MAX;

                return $aPosition - $bPosition;
            }
        );

        foreach ($children as $key => $child) {
            /* @var NavigationItem $child */
            $array['items'][$key] = $child->toArray();
        }

        return $array;
    }
public function toArray()
    {
        $array = [
            'title' => $this->getName(),
            'label' => $this->getLabel(),
            'icon' => $this->getIcon(),
            'action' => $this->getAction(),
            'mainRoute' => $this->getMainRoute(),
            'event' => $this->getEvent(),
            'eventArguments' => $this->getEventArguments(),
            'hasSettings' => $this->getHasSettings(),
            'disabled' => $this->getDisabled(),
            'id' => (null != $this->getId()) ? $this->getId() : str_replace('.', '', uniqid('', true)), //FIXME don't use uniqid()
        ];

        if (count($this->getChildRoutes()) > 0) {
            $array['childRoutes'] = $this->getChildRoutes();
        }

        if (null != $this->getHeaderIcon() || null != $this->getHeaderTitle()) {
            $array['header'] = [
                'title' => $this->getHeaderTitle(),
                'logo' => $this->getHeaderIcon(),
            ];
        }

        $children = $this->getChildren();

        usort(
            $children,
            function(NavigationItem $a, NavigationItem $b) {
                $aPosition = $a->getPosition() ?: PHP_INT_MAX;
                $bPosition = $b->getPosition() ?: PHP_INT_MAX;

                return $aPosition - $bPosition;
            }
        );

        foreach ($children as $key => $child) {
            /* @var NavigationItem $child */
            $array['items'][$key] = $child->toArray();
        }

        return $array;
    }
public function toArray ( ) { $ array = [ 'title' => $ this -> getName ( ) , 'label' => $ this -> getLabel ( ) , 'icon' => $ this -> getIcon ( ) , 'action' => $ this -> getAction ( ) , 'mainRoute' => $ this -> getMainRoute ( ) , 'event' => $ this -> getEvent ( ) , 'eventArguments' => $ this -> getEventArguments ( ) , 'hasSettings' => $ this -> getHasSettings ( ) , 'disabled' => $ this -> getDisabled ( ) , 'id' => ( null != $ this -> getId ( ) ) ? $ this -> getId ( ) : str_replace ( '.' , '' , uniqid ( '' , true ) ) , //FIXME don't use uniqid() ] ; if ( count ( $ this -> getChildRoutes ( ) ) > 0 ) { $ array [ 'childRoutes' ] = $ this -> getChildRoutes ( ) ; } if ( null != $ this -> getHeaderIcon ( ) || null != $ this -> getHeaderTitle ( ) ) { $ array [ 'header' ] = [ 'title' => $ this -> getHeaderTitle ( ) , 'logo' => $ this -> getHeaderIcon ( ) , ] ; } $ children = $ this -> getChildren ( ) ; usort ( $ children , function ( NavigationItem $ a , NavigationItem $ b ) { $ aPosition = $ a -> getPosition ( ) ? : PHP_INT_MAX ; $ bPosition = $ b -> getPosition ( ) ? : PHP_INT_MAX ; return $ aPosition - $ bPosition ; } ) ; foreach ( $ children as $ key => $ child ) { /* @var NavigationItem $child */ $ array [ 'items' ] [ $ key ] = $ child -> toArray ( ) ; } return $ array ; }
Returns the content of the NavigationItem as array.

@return array
Returns the content of the NavigationItem as array .