class MenuItemsTwigExtension in Simplify Menu 8.2
Same name and namespace in other branches
- 8 src/TwigExtension/MenuItemsTwigExtension.php \Drupal\simplify_menu\TwigExtension\MenuItemsTwigExtension
Class MenuItemsTwigExtension.
@package Drupal\simplify_menu
Hierarchy
- class \Drupal\simplify_menu\TwigExtension\MenuItemsTwigExtension extends \Drupal\simplify_menu\TwigExtension\Twig_Extension
Expanded class hierarchy of MenuItemsTwigExtension
1 string reference to 'MenuItemsTwigExtension'
1 service uses MenuItemsTwigExtension
File
- src/
TwigExtension/ MenuItemsTwigExtension.php, line 14
Namespace
Drupal\simplify_menu\TwigExtensionView source
class MenuItemsTwigExtension extends \Twig_Extension {
/**
* MenuItems definition.
*
* @var \Drupal\simplify_menu\MenuItems
*/
protected $menuItems;
/**
* MenuItemsTwigExtension constructor.
*
* @param \Drupal\simplify_menu\MenuItems $menuItems
* The MenuItems service.
*/
public function __construct(MenuItems $menuItems) {
$this->menuItems = $menuItems;
}
/**
* {@inheritdoc}
*/
public function getFunctions() : array {
return [
new \Twig_SimpleFunction('simplify_menu', function ($menuId = NULL) {
return $this->menuItems
->getMenuTree($menuId);
}, [
'is_safe' => [
'html',
],
]),
];
}
/**
* {@inheritdoc}
*/
public function getName() : string {
return 'simplify_menu';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MenuItemsTwigExtension:: |
protected | property | MenuItems definition. | |
MenuItemsTwigExtension:: |
public | function | ||
MenuItemsTwigExtension:: |
public | function | ||
MenuItemsTwigExtension:: |
public | function | MenuItemsTwigExtension constructor. |