class RouteSubscriber in Menu item content fields 8
Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\menu_item_fields_ui\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
- menu_item_fields_ui.services.yml in modules/
menu_item_fields_ui/ menu_item_fields_ui.services.yml - modules/menu_item_fields_ui/menu_item_fields_ui.services.yml
1 service uses RouteSubscriber
- menu_item_fields_ui.route_subscriber in modules/
menu_item_fields_ui/ menu_item_fields_ui.services.yml - Drupal\menu_item_fields_ui\Routing\RouteSubscriber
File
- modules/
menu_item_fields_ui/ src/ Routing/ RouteSubscriber.php, line 12
Namespace
Drupal\menu_item_fields_ui\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
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');
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-200,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |