You are here

public function MenuExampleController::routeOnly 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::routeOnly()

Give the user a link to the route-only page.

Throws

\InvalidArgumentException

1 string reference to 'MenuExampleController::routeOnly'
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 119

Class

MenuExampleController
Controller routines for menu example routes.

Namespace

Drupal\menu_example\Controller

Code

public function routeOnly() {
  $url = Url::fromRoute('examples.menu_example.route_only.callback');
  return [
    '#markup' => $this
      ->t('A menu entry with no menu link is at @link', [
      '@link' => Link::createFromRoute($url
        ->getInternalPath(), $url
        ->getRouteName())
        ->toString(),
    ]),
  ];
}