MenuItemsTwigExtension.php in Simplify Menu 8.2
File
src/TwigExtension/MenuItemsTwigExtension.php
View source
<?php
declare (strict_types=1);
namespace Drupal\simplify_menu\TwigExtension;
use Drupal\simplify_menu\MenuItems;
class MenuItemsTwigExtension extends \Twig_Extension {
protected $menuItems;
public function __construct(MenuItems $menuItems) {
$this->menuItems = $menuItems;
}
public function getFunctions() : array {
return [
new \Twig_SimpleFunction('simplify_menu', function ($menuId = NULL) {
return $this->menuItems
->getMenuTree($menuId);
}, [
'is_safe' => [
'html',
],
]),
];
}
public function getName() : string {
return 'simplify_menu';
}
}