mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
integration of knp menu bundle
This commit is contained in:
@@ -64,7 +64,10 @@ class MenuTwig extends \Twig_Extension implements ContainerAwareInterface
|
||||
public function getFunctions()
|
||||
{
|
||||
return [new \Twig_SimpleFunction('chill_menu',
|
||||
array($this, 'chillMenu'), array('is_safe' => array('html')))
|
||||
array($this, 'chillMenu'), array(
|
||||
'is_safe' => array('html'),
|
||||
'needs_environment' => true
|
||||
))
|
||||
];
|
||||
}
|
||||
|
||||
@@ -81,17 +84,22 @@ class MenuTwig extends \Twig_Extension implements ContainerAwareInterface
|
||||
* @param string $menuId
|
||||
* @param mixed[] $params
|
||||
*/
|
||||
public function chillMenu($menuId, array $params = array())
|
||||
public function chillMenu(\Twig_Environment $env, $menuId, array $params = array())
|
||||
{
|
||||
$resolvedParams = array_merge($this->defaultParams, $params);
|
||||
|
||||
$layout = $resolvedParams['layout'];
|
||||
unset($resolvedParams['layout']);
|
||||
|
||||
$resolvedParams['routes'] = $this->menuComposer->getRoutesFor($menuId);
|
||||
if ($this->menuComposer->hasLocalMenuBuilder($menuId) === false) {
|
||||
$resolvedParams['routes'] = $this->menuComposer->getRoutesFor($menuId, $resolvedParams);
|
||||
|
||||
return $this->container->get('templating')
|
||||
->render($layout, $resolvedParams);
|
||||
return $env->render($layout, $resolvedParams);
|
||||
} else {
|
||||
$resolvedParams['menus'] = $this->menuComposer->getMenuFor($menuId, $resolvedParams);
|
||||
|
||||
return $env->render($layout, $resolvedParams);
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
Reference in New Issue
Block a user