class MenuExampleDynamicRoutes
Same name in other branches
- 3.x modules/menu_example/src/Routing/MenuExampleDynamicRoutes.php \Drupal\menu_example\Routing\MenuExampleDynamicRoutes
Defines dynamic routes for our tab menu items.
These routes support the links created in menu_example.links.task.yml.
Hierarchy
- class \Drupal\menu_example\Routing\MenuExampleDynamicRoutes
Expanded class hierarchy of MenuExampleDynamicRoutes
See also
https://www.drupal.org/docs/8/api/routing-system/providing-dynamic-rout…
File
-
modules/
menu_example/ src/ Routing/ MenuExampleDynamicRoutes.php, line 15
Namespace
Drupal\menu_example\RoutingView source
class MenuExampleDynamicRoutes {
/**
* Returns an array of route objects.
*
* @return \Symfony\Component\Routing\Route[]
* An array of route objects.
*/
public function routes() {
$routes = [];
$tabs = [
'tabs' => 'Default primary tab',
'tabs/second' => 'Second',
'tabs/third' => 'Third',
'tabs/fourth' => 'Fourth',
'tabs/default/second' => 'Second',
'tabs/default/third' => 'Third',
];
foreach ($tabs as $path => $title) {
$machine_name = 'examples.menu_example.' . str_replace('/', '_', $path);
$routes[$machine_name] = new Route('/examples/menu-example/' . $path, [
'_controller' => '\\Drupal\\menu_example\\Controller\\MenuExampleController::tabsPage',
'_title' => $title,
'path' => $path,
'title' => $title,
], [
'_access' => 'TRUE',
]);
}
return $routes;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
MenuExampleDynamicRoutes::routes | public | function | Returns an array of route objects. |