function MenuExampleController::customAccess
Same name in other branches
- 3.x modules/menu_example/src/Controller/MenuExampleController.php \Drupal\menu_example\Controller\MenuExampleController::customAccess()
Demonstrates the use of custom access check in routes.
Throws
\InvalidArgumentException
See also
\Drupal\menu_example\Controller\MenuExampleController::customAccessPage()
1 string reference to 'MenuExampleController::customAccess'
- menu_example.routing.yml in modules/
menu_example/ menu_example.routing.yml - modules/menu_example/menu_example.routing.yml
File
-
modules/
menu_example/ src/ Controller/ MenuExampleController.php, line 92
Class
- MenuExampleController
- Controller routines for menu example routes.
Namespace
Drupal\menu_example\ControllerCode
public function customAccess() {
$url = Url::fromRoute('examples.menu_example.custom_access_page');
return [
'#markup' => $this->t('A menu item that requires the user to posess a role of "authenticated" is at @link', [
'@link' => Link::createFromRoute($url->getInternalPath(), $url->getRouteName())
->toString(),
]),
];
}