You are here

protected function RouteSubscriber::alterRoutes in Menu item content fields 8

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

modules/menu_item_fields_ui/src/Routing/RouteSubscriber.php, line 17

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\menu_item_fields_ui\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  foreach ([
    'entity.field_config.menu_link_content_field_edit_form',
    'entity.field_config.menu_link_content_storage_edit_form',
    'entity.field_config.menu_link_content_field_delete_form',
    'entity.menu_link_content.field_ui_fields',
    'field_ui.field_storage_config_add_menu_link_content',
    'entity.entity_form_display.menu_link_content.default',
    'entity.entity_form_display.menu_link_content.form_mode',
    'entity.entity_view_display.menu_link_content.default',
    'entity.entity_view_display.menu_link_content.view_mode',
  ] as $routeName) {
    if ($route = $collection
      ->get($routeName)) {
      $route
        ->setDefault('bundle', 'menu_link_content');
    }
  }
}