src/Parser.php
private function parseMenuItems($title, string $url, array $children, array $fields): Item
    {
        $urlGenerator = $this->instantiateUrlGenerator();

        // Extract parameters into variables
        if (is_array($title)) {
            extract($title);
        }

        // If child elements provided
        if ($children) {
            $childItems = [];

            foreach ($children as $child) {
                $this->checkFormat($child);

                // If child contains child elements, use recursively add them
                if (isset($child['children']) && $child['children']) {
                    $childItems[] = $this->parseMenuItems($child['title'], $child['url'], $child['children'],
                        $child['fields'] ?? []);
                } else {
                    $childItems[] = new Item($child['title'], $child['url'], [], $child['fields'] ?? [], new Config, $urlGenerator);
                }
            }
        }

        return new Item($title, $url, $childItems ?? $children, $fields, new Config, $urlGenerator);
    }
private function parseMenuItems($title, string $url, array $children, array $fields): Item
    {
        $urlGenerator = $this->instantiateUrlGenerator();

        // Extract parameters into variables
        if (is_array($title)) {
            extract($title);
        }

        // If child elements provided
        if ($children) {
            $childItems = [];

            foreach ($children as $child) {
                $this->checkFormat($child);

                // If child contains child elements, use recursively add them
                if (isset($child['children']) && $child['children']) {
                    $childItems[] = $this->parseMenuItems($child['title'], $child['url'], $child['children'],
                        $child['fields'] ?? []);
                } else {
                    $childItems[] = new Item($child['title'], $child['url'], [], $child['fields'] ?? [], new Config, $urlGenerator);
                }
            }
        }

        return new Item($title, $url, $childItems ?? $children, $fields, new Config, $urlGenerator);
    }
private function parseMenuItems ( $ title , string $ url , array $ children , array $ fields ) : Item { $ urlGenerator = $ this -> instantiateUrlGenerator ( ) ; // Extract parameters into variables if ( is_array ( $ title ) ) { extract ( $ title ) ; } // If child elements provided if ( $ children ) { $ childItems = [ ] ; foreach ( $ children as $ child ) { $ this -> checkFormat ( $ child ) ; // If child contains child elements, use recursively add them if ( isset ( $ child [ 'children' ] ) && $ child [ 'children' ] ) { $ childItems [ ] = $ this -> parseMenuItems ( $ child [ 'title' ] , $ child [ 'url' ] , $ child [ 'children' ] , $ child [ 'fields' ] ?? [ ] ) ; } else { $ childItems [ ] = new Item ( $ child [ 'title' ] , $ child [ 'url' ] , [ ] , $ child [ 'fields' ] ?? [ ] , new Config , $ urlGenerator ) ; } } } return new Item ( $ title , $ url , $ childItems ?? $ children , $ fields , new Config , $ urlGenerator ) ; }
Parse menu items by converting them into instances of Item.
Parse menu items by converting them into instances of Item .