'@ChillMain/Menu/defaultMenu.html.twig', 'args' => [], 'activeRouteKey' => null, ]; public function __construct(private readonly MenuComposer $menuComposer) {} /** * Render a Menu corresponding to $menuId. * * Expected params : * - args: the arguments to build the path (i.e: if pattern is /something/{bar}, args must contain {'bar': 'foo'} * - layout: the layout. Absolute path needed (i.e.: @ChillXyz/section/foo.html.twig) * - activeRouteKey : the key active, will render the menu differently. * * @deprecated link: see https://redmine.champs-libres.coop/issues/179 for more informations * * @param string $menuId * @param mixed[] $params */ public function chillMenu(Environment $env, $menuId, array $params = []) { $resolvedParams = array_merge($this->defaultParams, $params); $layout = $resolvedParams['layout']; unset($resolvedParams['layout']); if ($this->menuComposer->hasLocalMenuBuilder($menuId) === false) { $resolvedParams['routes'] = $this->menuComposer->getRoutesFor($menuId, $resolvedParams); return $env->render($layout, $resolvedParams); } $resolvedParams['menus'] = $this->menuComposer->getMenuFor($menuId, $resolvedParams); return $env->render($layout, $resolvedParams); } public function getFunctions() { return [new TwigFunction( 'chill_menu', $this->chillMenu(...), [ 'is_safe' => ['html'], 'needs_environment' => true, ] ), ]; } public function getName() { return 'chill_menu'; } public function setContainer(?ContainerInterface $container = null) { $this->container = $container; } }