You are here

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

Demonstrate how one can alter the existing routes.

1 string reference to 'MenuExampleController::pathOverride'
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 262

Class

MenuExampleController
Controller routines for menu example routes.

Namespace

Drupal\menu_example\Controller

Code

public function pathOverride() {
  return [
    '#markup' => $this
      ->t('This menu item was created strictly to allow the RouteSubscriber class to have something to operate on. menu_example.routing.yml defined the path as examples/menu-example/menu-original-path. The alterRoutes() changes it to /examples/menu-example/menu-altered-path. You can try navigating to both paths and see what happens!'),
  ];
}