public function MenuExampleController::pathOverride in Examples for Developers 8
Same name and namespace in other branches
- 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\ControllerCode
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!'),
];
}