You are here

class MenuItemsTwigExtension in Simplify Menu 8.2

Same name and namespace in other branches
  1. 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'
simplify_menu.services.yml in ./simplify_menu.services.yml
simplify_menu.services.yml
1 service uses MenuItemsTwigExtension
simplify_menu.menu_items_twig_extension in ./simplify_menu.services.yml
Drupal\simplify_menu\TwigExtension\MenuItemsTwigExtension

File

src/TwigExtension/MenuItemsTwigExtension.php, line 14

Namespace

Drupal\simplify_menu\TwigExtension
View 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

Namesort descending Modifiers Type Description Overrides
MenuItemsTwigExtension::$menuItems protected property MenuItems definition.
MenuItemsTwigExtension::getFunctions public function
MenuItemsTwigExtension::getName public function
MenuItemsTwigExtension::__construct public function MenuItemsTwigExtension constructor.