<?php
namespace App\Twig;
use App\Services\Menu\Core;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Twig\TwigFilter;
class MenuExtension extends AbstractExtension
{
public function __construct(Core $coreMenu)
{
$this->menu = $coreMenu;
}
public function getFunctions(): array
{
return [
new TwigFunction('getMenu', [$this, 'getMenu']),
new TwigFunction('getMenuItems', [$this, 'getMenuItems']),
new TwigFunction('getMenuWebsiteArray', [$this, 'getMenuWebsiteArray']),
new TwigFunction('getMenuWebsiteItems', [$this, 'getMenuWebsiteItems']),
];
}
/**
* Menu -> 1er niveau
*/
public function getMenu($locale)
{
return $this->menu->getMenu($locale);
}
/**
* Sous menu
*/
public function getMenuItems($menuId)
{
return $this->menu->getMenuItems($menuId);
}
public function getMenuWebsiteItems($parentID) {
return $this->menu->getMenuWebsiteItems($parentID);
}
public function getMenuWebsiteArray($type,$connectuser = null)
{
return $this->menu->getMenuWebsiteArray($type,$connectuser);
}
}