protected function WebformRouteSubscriber::alterRoutes in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Routing/WebformRouteSubscriber.php \Drupal\webform\Routing\WebformRouteSubscriber::alterRoutes()
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- src/
Routing/ WebformRouteSubscriber.php, line 45
Class
- WebformRouteSubscriber
- Adds the _admin_route option to webform routes.
Namespace
Drupal\webform\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
// Set admin route for webform admin routes.
foreach ($collection
->all() as $route) {
if (!$route
->hasOption('_admin_route') && (strpos($route
->getPath(), '/admin/structure/webform/') === 0 || strpos($route
->getPath(), '/webform/results/') !== FALSE)) {
$route
->setOption('_admin_route', TRUE);
}
// Change /admin/structure/webform/ to /admin/webform/.
if ($this->configFactory
->get('webform.settings')
->get('ui.toolbar_item')) {
if (strpos($route
->getPath(), '/admin/structure/webform') === 0) {
$path = str_replace('/admin/structure/webform', '/admin/webform', $route
->getPath());
$route
->setPath($path);
}
}
}
// If the webform_share.module is not enabled, remove variant share route.
if (!$this->moduleHandler
->moduleExists('webform_share')) {
$collection
->remove('entity.webform.variant.share_form');
}
}