append menu entries of configuration to a
previously created Menu instance

@param \DOMNodeList $entries
@param Menu $menu
@throws ConfigException
178892
private function appendMenuEntries(\DOMNodeList $entries, Menu $menu) {

		foreach($entries as $entry) {

			if($entry->nodeType !== XML_ELEMENT_NODE || 'menuentry' !== $entry->nodeName) {
				continue;
			}

			// read additional attributes which are passed to menu entry constructor

			$attributes = [];

			foreach($entry->attributes as $attr) {

				$nodeName = $attr->nodeName;

				if(!in_array($nodeName, ['page', 'path', 'auth', 'auth_parameters'])) {
					$attributes[$attr->nodeName] = $attr->nodeValue;
				}

			}

			if('menuentry' === $entry->nodeName) {

				$page = $entry->getAttribute('page');
				$path = $entry->getAttribute('path');

				if($page && $path) {

					throw new ConfigException(sprintf("Menu entry with both page ('%s') and path ('%s') attribute found.", $page, $path));

				}

				// menu entry comes with a path attribute (which can also link an external resource)

				if($path) {

					$local = strpos($path, '/') !== 0 && !preg_match('~^[a-z]+://~', $path);

					$e = new MenuEntry($path, $attributes, $local);

				}

				// menu entry comes with a page attribute, in this case the route path is used

				else if($page) {

					if(!isset($this->routes[$menu->getScript()][$page])) {

						throw new ConfigException(sprintf(
							"No route for menu entry ('%s') found. Available routes for script '%s' are '%s'.",
							$page,
							$menu->getScript(),
							empty($this->routes[$menu->getScript()]) ? 'none' : implode("', '", array_keys($this->routes[$menu->getScript()]))
						));

					}

					$e = new MenuEntry((string) $this->routes[$menu->getScript()][$page]->getPath(), $attributes, true);

				}

				// handle authentication settings of menu entry

				if(($auth = strtolower(trim($entry->getAttribute('auth'))))) {

					// set optional authentication level

					$e->setAuth($auth);

					// if auth level is defined, additional authentication parameters can be set

					if(($authParameters = $entry->getAttribute('auth_parameters'))) {
						$e->setAuthParameters($authParameters);
					}

				}

				$menu->appendEntry($e);

				$submenu = (new \DOMXPath($entry->ownerDocument))->query('menu', $entry); 

				if($submenu->length) {
					$e->appendMenu($this->parseMenu($submenu->item(0)));
				}

			}

			else if($entry->nodeName === 'menuentry_placeholder') {

				$e = new DynamicMenuEntry(null, $attributes);
				$menu->appendEntry($e);

			}
		}
	}
620903
private function appendChildren(ItemInterface $menu)
    {
        foreach ($this->pool->getGroups() as $group) {

            $groupOptions = [
                'labelAttributes' => ['icon' => $group->getIcon()],
                'childrenAttributes' => ['class' => 'submenu']
            ];

            if ($group->hasEntries()) {
                $groupOptions['labelAttributes']['class'] = 'dropdown-toggle';

                $groupEntries = [];
                foreach ($group->getEntries() as $entry) {
                    if (!$this->entrySecurityCheck($entry)) {
                        continue;
                    }

                    $groupEntry = $this->factory->createItem($entry->getName(), [
                        'route' => $entry->getRoute()
                    ]);
                    $groupEntry
                        ->setLabel($entry->getLabel())
                        ->setExtra('translation_domain', $entry->getDomain())
                    ;

                    $groupEntries[] = $groupEntry;
                }

                if (0 < count($groupEntries)) {
                    $menuGroup = $menu
                        ->addChild($group->getName(), $groupOptions)
                        ->setLabel($group->getLabel())
                        ->setExtra('translation_domain', $group->getDomain())
                    ;
                    foreach ($groupEntries as $groupEntry) {
                        $menuGroup->addChild($groupEntry);
                    }
                }
            } else {
                $groupOptions['route'] = $group->getRoute();
                $menu
                    ->addChild($group->getName(), $groupOptions)
                    ->setLabel($group->getLabel())
                    ->setExtra('translation_domain', $group->getDomain())
                ;
            }
        }
    }
863376
public function setEntry(Entry $entry)
    {
        $entry->format = $this->format;
        $entry->prepare();

        $this->entries->add($entry);
    }
1233243
private function parseMenusSettings(\DOMNode $menus) {

		foreach ((new \DOMXPath($menus->ownerDocument))->query('menu', $menus) as $menu) {

			$id = $menu->getAttribute('id') ?: Menu::DEFAULT_ID;

			if(isset($this->menus[$id])) {
				$this->appendMenuEntries($menu->childNodes, $this->menus[$id]);
			}
			else {
				$this->menus[$id] = $this->parseMenu($menu);
			}

		}

	}
669439
private function parseMenu(\DOMNode $menu) {

		$root = $menu->getAttribute('script');

		if(!$root) {
			if($this->site) {
				$root= $this->site->root_document ?: 'index.php';
			}
			else {
				$root= 'index.php';
			}
		}

		$type = $menu->getAttribute('type') === 'dynamic' ? 'dynamic' : 'static';
		$service = $menu->getAttribute('service') ?: NULL;
		$id = $menu->getAttribute('id') ?: NULL;

		if($type === 'dynamic' && !$service) {
			throw new ConfigException("A dynamic menu requires a configured service.");
		}

		$m = new Menu(
			$root,
			$id,
			$type,
			$service
		);

		if(($menuAuth = strtolower(trim($menu->getAttribute('auth'))))) {

			$m->setAuth($menuAuth);

			// if an auth level is defined, additional authentication parameters can be set

			if(($authParameters = $menu->getAttribute('auth_parameters'))) {
				$m->setAuthParameters($authParameters);
			}

		}

		$this->appendMenuEntries($menu->childNodes, $m);

		return $m;

	}
750587
public function appendConfiguration(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('vcs')
                    ->children()
                        ->scalarNode('url')->end()
                        ->arrayNode('export')
                            ->children()
                                ->scalarNode('revfile')->isRequired()->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
45427
protected function createMenus($menus)
    {
        $locations = [];

        foreach ($menus as $menu) {
            $menu_id = $this->createMenu($menu['name']);

            if ($menu_id) {
                $locations[$menu['location']] = $menu_id;
                $this->populateMenu($menu_id, $menu['items']);
            }
        }

        set_theme_mod('nav_menu_locations', $locations);
    }
226953
public function addProductionMenuItems(MenuCollectionEvent $event): void
    {
        // We only operate on group member users.
        $user = $this->token_storage->getToken()->getUser();
        if (!$user instanceof GroupMemberInterface) {
            return;
        }

        // Create productions menu dropdown item.
        $productions = $this->factory->createItem('menu_item.productions', [
            'extras' => ['translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN],
        ]);

        $items = [];
        foreach ($user->getMemberships() as $membership) {
            // Get the group for this membership, if not a production skip out.
            $group = $membership->getGroup();

            // If the membership and production are active and not expired.
            if ($membership->isActive()
                && !$membership->isExpired()
                && $group->isActive()
                && !$group->isExpired()) {
                // The membership is good, add a menu item.
                $items[] = $this->factory->createItem($membership->getGroup()->getName(), [
                    'route' => 'bkstg_production_read',
                    'routeParameters' => ['production_slug' => $membership->getGroup()->getSlug()],
                    'extras' => ['translation_domain' => false],
                ]);
            }
        }

        if (0 === count($user->getMemberships())) {
            $productions->addChild($this->factory->createItem('menu_item.no_productions', [
                'uri' => '#',
                'extras' => [
                    'translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN,
                ],
            ]));
        } else {
            // Add all children (in alpha order) to production item.
            usort($items, function ($a, $b) {
                return strcasecmp($a->getLabel(), $b->getLabel());
            });
            $productions->setChildren($items);
        }

        // Add the production menu item to the main menu.
        $menu = $event->getMenu();
        $menu->addChild($productions);
    }
45059
public function setMenu(\Wucdbm\Bundle\MenuBuilderBundle\Entity\Menu $menu) {
        $this->menu = $menu;

        return $this;
    }
494396
protected function addButtons(\Gems_Menu_MenuList $menuList)
    {
        if ($this->addCurrentParent) {
            $menuList->addCurrentParent($this->_('Cancel'));
        }
        if ($this->addCurrentSiblings) {
            $menuList->addCurrentSiblings($this->anyParameterSiblings);
        }
        if ($this->addCurrentChildren) {
            $menuList->addCurrentChildren();
        }
        // \MUtil_Echo::track($this->addCurrentParent, $this->addCurrentSiblings, $this->addCurrentChildren, count($menuList));
    }
709655
public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('menu.xml');

        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        foreach ($config['providers'] as $builder => $enabled) {
            if ($enabled) {
                $container->getDefinition(sprintf('knp_menu.menu_provider.%s', $builder))->addTag('knp_menu.provider');
            }
        }

        if (isset($config['twig'])) {
            $loader->load('twig.xml');
            $container->setParameter('knp_menu.renderer.twig.template', $config['twig']['template']);
        }
        if ($config['templating']) {
            $loader->load('templating.xml');
        }

        $container->setParameter('knp_menu.default_renderer', $config['default_renderer']);

        // Register autoconfiguration rules for Symfony DI 3.3+
        if (method_exists($container, 'registerForAutoconfiguration')) {
            $container->registerForAutoconfiguration(VoterInterface::class)
                ->addTag('knp_menu.voter');
        }
    }
1172015
protected function processBreadcrumbEntries(MenuEntry $entry)
    {
        $entries = array(
            $entry
        );
        
        if ($entry->hasParent()) {
            $parentEntries = $this->processBreadcrumbEntries($entry->getParent());
        
            foreach ($parentEntries as $parentEntry) {
                $entries[] = $parentEntry;
            }
        }
        
        return $entries;
    }
10833
public function addEntry( $entry, $section )
	{
		if( isset( $this->list[$section] ) && is_array( $this->list[$section] ) && in_array( $entry, $this->list[$section] ) )
			throw new InvalidArgumentException( 'Entry "'.$entry.'" is already in Section "'.$section.'".' );
		$this->list[$section][] = $entry;
	}
155404
public function add(): void
    {
        $menu = $this->Menus->newEntity();
        if ($this->request->is('post')) {
            $data = (array)$this->request->getData();
            $menu = $this->Menus->patchEntity($menu, $data);
            if ($this->Menus->save($menu)) {
                $this->Flash->success((string)__('The menu has been saved.'));
                $this->redirect(['action' => 'index']);

                return;
            } else {
                $this->Flash->error((string)__('The menu could not be saved. Please, try again.'));
            }
        }
        $this->set('navMenu', $menu);
        $this->set('_serialize', ['navMenu']);
    }
488954
private function addMenuSection(ArrayNodeDefinition $node)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $node
            ->children()
                ->arrayNode('menu')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('roots')
                            ->defaultValue(['main' => [
                                'title'       => 'Navigation principale',
                                'description' => 'Barre de navigation principale',
                            ]])
                            ->useAttributeAsKey('name')
                            ->prototype('array')
                                ->children()
                                    ->scalarNode('title')->isRequired()->cannotBeEmpty()->end()
                                    ->scalarNode('description')->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
248979
private void createMenus(Collection<ActionRef> parents, Collection<ActionRef> actions)
    {
        for (final ActionRef action : actions)
        {
            final Featurable menu = createMenu(action);
            if (!action.getRefs().isEmpty())
            {
                generateSubMenu(actions, action, menu);
            }
            else if (action.hasCancel())
            {
                previous.put(action, parents);
                generateCancel(action, menu);
            }
        }
        for (final Featurable current : menus)
        {
            handler.add(current);
        }
    }
988096
protected static function createEntries(Container $container, array $entries)
    {
        $defaultShared = $container->isSharedByDefault();

        foreach ($entries as $entry) {
            foreach (self::$requiredEntryKeys as $key) {
                if (!isset($entry[$key])) {
                    $message = sprintf('Missing required entry key "%s" in "%s".', $key, __METHOD__);
                    throw new Exception\InvalidArgumentException($message);
                }
            }

            if (!in_array($entry[ContainerInterface::CONFIG_ENTRY_TYPE], self::$entryTypes)) {
                throw new Exception\InvalidArgumentException(sprintf(
                    'Value "%s" for "%s" is not valid; it must be one of "%s" in "%s".',
                    $entry[ContainerInterface::CONFIG_ENTRY_TYPE],
                    $key,
                    implode(', ', self::$types),
                    __METHOD__
                ));
            }

            $shared = isset($entry[ContainerInterface::CONFIG_ENTRY_SHARED]) ? (bool) $entry[ContainerInterface::CONFIG_ENTRY_SHARED] : $defaultShared;

            $container->add($entry[ContainerInterface::CONFIG_ENTRY_NAME], $entry[ContainerInterface::CONFIG_ENTRY_VALUE], $entry[ContainerInterface::CONFIG_ENTRY_TYPE], $shared);
        }
    }