private function buildItem(array $data, array $options = [])
    {
        $options = array_merge($options, [
            'label' => $data['title'],
        ]);
        if (!empty($data['attributes'])) {
            $options['attributes'] = $data['attributes'];
        }

        // Fix routing / url / path
        if (0 < strlen($data['path'])) {
            $options['uri'] = $data['path'];
        } elseif (0 < strlen($data['route'])) {
            $options['route'] = $data['route'];
            if (!empty($data['parameters'])) {
                $options['routeParameters'] = $data['parameters'];
            }
        }

        $item = $this
            ->factory
            ->createItem($data['name'], $options)
            ->setExtra('translation_domain', false);

        // Children items
        foreach ($this->menus as $menu) {
            if ($data['id'] === intval($menu['parent'])) {
                $item->addChild($this->buildItem($menu));
            }
        }

        // Custom menu event
        if (isset($data['options']['event']) && 0 < strlen($event = $data['options']['event'])) {
            $this->dispatcher->dispatch($event, new MenuEvent($this->factory, $item));
        }

        return $item;
    }
private function buildItem(array $data, array $options = [])
    {
        $options = array_merge($options, [
            'label' => $data['title'],
        ]);
        if (!empty($data['attributes'])) {
            $options['attributes'] = $data['attributes'];
        }

        // Fix routing / url / path
        if (0 < strlen($data['path'])) {
            $options['uri'] = $data['path'];
        } elseif (0 < strlen($data['route'])) {
            $options['route'] = $data['route'];
            if (!empty($data['parameters'])) {
                $options['routeParameters'] = $data['parameters'];
            }
        }

        $item = $this
            ->factory
            ->createItem($data['name'], $options)
            ->setExtra('translation_domain', false);

        // Children items
        foreach ($this->menus as $menu) {
            if ($data['id'] === intval($menu['parent'])) {
                $item->addChild($this->buildItem($menu));
            }
        }

        // Custom menu event
        if (isset($data['options']['event']) && 0 < strlen($event = $data['options']['event'])) {
            $this->dispatcher->dispatch($event, new MenuEvent($this->factory, $item));
        }

        return $item;
    }
private function buildItem ( array $ data , array $ options = [ ] ) { $ options = array_merge ( $ options , [ 'label' => $ data [ 'title' ] , ] ) ; if ( ! empty ( $ data [ 'attributes' ] ) ) { $ options [ 'attributes' ] = $ data [ 'attributes' ] ; } // Fix routing / url / path if ( 0 < strlen ( $ data [ 'path' ] ) ) { $ options [ 'uri' ] = $ data [ 'path' ] ; } elseif ( 0 < strlen ( $ data [ 'route' ] ) ) { $ options [ 'route' ] = $ data [ 'route' ] ; if ( ! empty ( $ data [ 'parameters' ] ) ) { $ options [ 'routeParameters' ] = $ data [ 'parameters' ] ; } } $ item = $ this -> factory -> createItem ( $ data [ 'name' ] , $ options ) -> setExtra ( 'translation_domain' , false ) ; // Children items foreach ( $ this -> menus as $ menu ) { if ( $ data [ 'id' ] === intval ( $ menu [ 'parent' ] ) ) { $ item -> addChild ( $ this -> buildItem ( $ menu ) ) ; } } // Custom menu event if ( isset ( $ data [ 'options' ] [ 'event' ] ) && 0 < strlen ( $ event = $ data [ 'options' ] [ 'event' ] ) ) { $ this -> dispatcher -> dispatch ( $ event , new MenuEvent ( $ this -> factory , $ item ) ) ; } return $ item ; }
Builds the menu item.

@param array $data
@param array $options

@return \Knp\Menu\ItemInterface
Builds the menu item .