protected function RouteSubscriber::alterRoutes in Sitewide Alert 8
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/ RouteSubscriber.php, line 19
Class
- RouteSubscriber
- Class RouteSubscriber.
Namespace
Drupal\sitewide_alert\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
// Disable access to field UI for Sitewide Alerts.
// Currently adding and configuring fields has little effect.
$sitewideAlertFieldUiRoutesNames = [
'entity.field_config.sitewide_alert_field_edit_form',
'entity.field_config.sitewide_alert_storage_edit_form',
'entity.field_config.sitewide_alert_storage_edit_form',
'entity.sitewide_alert.field_ui_fields',
'field_ui.field_storage_config_add_sitewide_alert',
'entity.entity_form_display.sitewide_alert.default',
'entity.entity_form_display.sitewide_alert.form_mode',
'entity.entity_view_display.sitewide_alert.default',
'entity.entity_view_display.sitewide_alert.view_mode',
];
foreach ($sitewideAlertFieldUiRoutesNames as $routeName) {
if ($route = $collection
->get($routeName)) {
$route
->setRequirement('_access', 'FALSE');
}
}
}