Creates link to uri element and adds it to menu

@param \Knp\Menu\ItemInterface $menu
@param string $label Link label
@param string $route Link uri
@return ItemInterface Link element
977492
protected function addLinkURI(ItemInterface $menu, $label, $uri)
    {
        $item = $menu->addChild($label, array('uri' => $uri));
        $item->setExtra('translation_domain', $this->translation_domain);

        if ($item->getUri() == $this->container->get('request')->getRequestUri()) {
            $item->setAttribute('class', 'active');
        }

        return $item;
    }
522373
protected static function createRouteUrl(
        ContainerInterface $container,
        string $routeName,
        array $placeholders = [],
        array $queryParams = []
    ): string {
        /** @var RouterInterface $router */
        $router = $container->get(RouterInterface::class);

        $hostUri = static::getHostUri($container);
        $url     = $router->get($hostUri, $routeName, $placeholders, $queryParams);

        return $url;
    }
134242
public function addChild($label, $link, $index = -1){
		$this->children[$link] = new Toc($label, $link);
		return $this->children[$link];
	}
1096695
public function breadcrumbAppend($name, $label, $route = null, array $parameters = [])
    {
        $this->createBreadcrumb();

        $this
            ->breadcrumb
            ->addChild($name, ['route' => $route, 'routeParameters' => $parameters])
            ->setLabel($label)
        ;
    }
387325
public function showMenu($menu, $layout = null, $activeLink= null) {
		
		if( $layout === null ) {
			$layout = defined('LAYOUT_MENU') ? LAYOUT_MENU : 'menu-default';
		}
		if( !$activeLink === null) {
			$activeLink = get_current_link();
		}
		
		$env = array('menu' => $menu, 'items' => array());
		$items = $this->getMenuItems($menu);
		if( empty($items) ) {
			return false;
		}
		foreach( $items as $itemConf ) {
			if( empty($itemConf) ) {
				continue;
			}
			if( $itemConf[0] === '\\' ) {
				// Callback
				$env['items'] = array_merge($env['items'], call_user_func($itemConf));
				
			} else {
				if( $itemConf[0] === '#' ) {
					// Static link with link & label hardcoded
					// Can not be active
					$itemParts = explodeList('|', substr($itemConf, 1), 2);
					$item = new MenuItem($itemParts[0], t($itemParts[1]));
					
				} else {
					// TODO: Allow {var:value} for values, or use a YAML config ?
					$routeName = $itemConf;
					
					/* @var $route HTTPRoute */
					$route = Route::getRoute($routeName);
					
					// Does not exist or is not acessible
					if( !$route || !$route->isAccessible()) {
						continue;
					}
					
					$item = new MenuItem(u($routeName), t($routeName));
					$item->setRoute($routeName);
				}
				$env['items'][] = $item;
			}
		}
		foreach( $env['items'] as $item) {
			if( $activeLink === $item->getLink() ) {
				$item->setActive();
			}
		}
		$this->display($layout, $env);
	}
1077501
public function linkRoute($route, $name, $parameters=array(), $position="BL", $attributes=array())
    {
        return $this->link(route($route, $parameters), $name, $position, $attributes);
    }
50071
public function setActionEdit(
        string $route = null,
        array $params = [],
        string $label = '',
        string $title = 'Edit',
        string $class = '',
        string $icon = 'fa fa-pencil'
    ): ButtonInterface {
        $this->setAction(self::TYPE_ACTION_EDIT)
            ->setRoute($route, $params)
            ->setLabel($label)
            ->setTitle($title)
            ->setClass($class)
            ->setIcon($icon);

        return $this;
    }
396078
protected function createPageLink($label, $page, $disabled, $active)
    {
        return array(
            'label' => $label,
            'url' => $this->createPageUrl($page),
            'disabled' => $disabled,
            'active' => $active,
        );
    }
250157
protected function createRoute(RouteInterface $route, Request $request)
    {
        $routePath = $this->decodePathInfo($request->getPathInfo());

        if ($route->isHistory()) {
            return new Route(
                $routePath,
                [
                    '_controller' => 'SuluWebsiteBundle:Redirect:redirect',
                    'url' => $request->getSchemeAndHttpHost()
                        . $this->requestAnalyzer->getResourceLocatorPrefix()
                        . $route->getTarget()->getPath()
                        . ($request->getQueryString() ? ('?' . $request->getQueryString()) : ''),
                ]
            );
        }

        $symfonyRoute = $this->proxyFactory->createProxy(
            Route::class,
            function(&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) use (
                $routePath,
                $route,
                $request
            ) {
                $initializer = null; // disable initialization
                $wrappedObject = new Route(
                    $routePath,
                    $this->routeDefaultsProvider->getByEntity(
                        $route->getEntityClass(),
                        $route->getEntityId(),
                        $request->getLocale()
                    )
                );

                return true;
            }
        );

        return $this->symfonyRouteCache[$route->getId()] = $symfonyRoute;
    }
117933
protected function fillMenu(ItemInterface $menu, $categories, array $options = [], $currentUri = null)
    {
        foreach ($categories as $category) {
            if (false === $category->getEnabled()) {
                continue;
            }

            $fullOptions = array_merge([
                'attributes' => ['class' => ''],      // Ensuring it is set
                'route' => 'sonata_catalog_category',
                'routeParameters' => [
                    'category_id' => $category->getId(),
                    'category_slug' => $category->getSlug(),
                ],
                'extras' => [
                    'safe_label' => true,
                ],
            ], $options);

            if (null === $category->getParent()) {
                $fullOptions['attributes']['class'] = 'lead '.$fullOptions['attributes']['class'];
            }

            $child = $menu->addChild(
                $this->getCategoryTitle($category),
                $fullOptions
            );

            if (\count($category->getChildren()) > 0) {
                if (null === $category->getParent()) {
                    $this->fillMenu($menu, $category->getChildren(), $options, $currentUri);
                } else {
                    $this->fillMenu($child, $category->getChildren(), $options, $currentUri);
                }
            }
        }
    }
701783
public function addCurrentRoute($label = null)
    {
        $base = Base::instance();
        $args = ($base['PARAMS'] ?: []) + ($base['GET'] ?: []);
        unset($args[0]);

        return $this->add($base['ALIAS'], $args, $label);
    }
687326
private function addLayoutsSubMenu(ItemInterface $menu): void
    {
        $menuOrder = $this->getNewMenuOrder($menu);

        $layouts = $menu
            ->addChild('nglayouts')
            ->setLabel('menu.main_menu.header')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('layout_resolver', ['route' => 'ngbm_admin_layout_resolver_index'])
            ->setLabel('menu.main_menu.layout_resolver')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('layouts', ['route' => 'ngbm_admin_layouts_index'])
            ->setLabel('menu.main_menu.layouts')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('shared_layouts', ['route' => 'ngbm_admin_shared_layouts_index'])
            ->setLabel('menu.main_menu.shared_layouts')
            ->setExtra('translation_domain', 'ngbm_admin');

        $menu->reorderChildren($menuOrder);
    }
233145
protected function addMenu(ItemInterface $parentMenu, $routeName, $menuLabel, $icon = 'fa-bars', $classCss = '')
    {
        try {
            return $parentMenu->addChild($menuLabel, array(
                'route' => $routeName,
                'label' => sprintf('<i class="fa %s" aria-hidden="true"></i> <span>%s</span>', $icon, $this->translator->trans($menuLabel, array(), $this->translationDomain)),
                'extras' => array(
                    'safe_label' => true,
                    'translation_domain' => false,
                ),
                'attributes' => array(
                    'class' => $classCss,
                ),
            ));
        } catch (\Exception $exception) {
            return $parentMenu->addChild($menuLabel, array(
                'uri' => sprintf('#%s', $routeName),
                'label' => sprintf('<i class="fa %s" aria-hidden="true"></i> <span>%s</span>', $icon, $this->translator->trans($menuLabel, array(), $this->translationDomain)),
                'extras' => array(
                    'safe_label' => true,
                    'translation_domain' => false,
                ),
                'attributes' => array(
                    'class' => $classCss,
                ),
            ));
        }
    }
390275
public function createMenu(): ItemInterface
    {
        $menu = $this->factory->createItem('root');

        if ($this->authorizationChecker->isGranted('nglayouts:ui:access')) {
            $menu
                ->addChild('layout_resolver', ['route' => 'ngbm_admin_layout_resolver_index'])
                ->setLabel('menu.main_menu.layout_resolver')
                ->setExtra('translation_domain', 'ngbm_admin');

            $menu
                ->addChild('layouts', ['route' => 'ngbm_admin_layouts_index'])
                ->setLabel('menu.main_menu.layouts')
                ->setExtra('translation_domain', 'ngbm_admin');

            $menu
                ->addChild('shared_layouts', ['route' => 'ngbm_admin_shared_layouts_index'])
                ->setLabel('menu.main_menu.shared_layouts')
                ->setExtra('translation_domain', 'ngbm_admin');
        }

        $this->eventDispatcher->dispatch(
            new ConfigureMenuEvent($this->factory, $menu),
            BlockManagerAdminEvents::CONFIGURE_MENU
        );

        return $menu;
    }
692112
public function setRoute(string $route = null, array $params = []): ButtonInterface
    {
        if ($this->isVisibility()) {
            if ($route === null) {
                $url = '#';
            } else {
                $url = '#';
                if (app('router')->has($route)) {
                    $url = route($route, $params);
                } else {
                    $this->setVisible(false);
                }
            }
            $this->setUrl($url);
        }

        return $this;
    }
1255100
public function link($url, $label = null)
    {
        $url = $this->h($this->fullUrl($url));

        return '<a href="'.$url.'">'.($label ? $this->h($label) : $url).'</a>';
    }
1348049
public function addResourceRoute(RouteInterface $resourceRoute
    ): RouteInterface
    {
        $resourceRoute->setIdentifier('route' . $this->routeCounter++);
        // Add route
        $this->routes[$resourceRoute->getIdentifier()] = $resourceRoute;

        return $resourceRoute;
    }