You are here

public function MenuExampleController::permissioned in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/menu_example/src/Controller/MenuExampleController.php \Drupal\menu_example\Controller\MenuExampleController::permissioned()

A menu entry with simple permissions using 'access protected menu example'.

Throws

\InvalidArgumentException

1 string reference to 'MenuExampleController::permissioned'
menu_example.routing.yml in menu_example/menu_example.routing.yml
menu_example/menu_example.routing.yml

File

menu_example/src/Controller/MenuExampleController.php, line 65

Class

MenuExampleController
Controller routines for menu example routes.

Namespace

Drupal\menu_example\Controller

Code

public function permissioned() {
  $url = Url::fromRoute('examples.menu_example.permissioned_controlled');
  return [
    '#markup' => $this
      ->t('A menu item that requires the "access protected menu example" permission is at @link', [
      '@link' => Link::createFromRoute($url
        ->getInternalPath(), $url
        ->getRouteName())
        ->toString(),
    ]),
  ];
}