class RouteSubscriber in Language Hierarchy 8
Same name and namespace in other branches
- 2.x src/Routing/RouteSubscriber.php \Drupal\language_hierarchy\Routing\RouteSubscriber
Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\language_hierarchy\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
Routing/ RouteSubscriber.php, line 13
Namespace
Drupal\language_hierarchy\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* The mapper plugin discovery service.
*
* @var \Drupal\config_translation\ConfigMapperManagerInterface
*/
protected $mapperManager;
/**
* Constructs a new RouteSubscriber.
*
* @param \Drupal\config_translation\ConfigMapperManagerInterface $mapper_manager
* The mapper plugin discovery service.
*/
public function __construct(ConfigMapperManagerInterface $mapper_manager) {
$this->mapperManager = $mapper_manager;
}
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
$mappers = $this->mapperManager
->getMappers($collection);
foreach ($mappers as $mapper) {
$route = $collection
->get($mapper
->getOverviewRouteName());
if ($route
->getDefault('_controller') === '\\Drupal\\config_translation\\Controller\\ConfigTranslationController::itemPage') {
$route
->setDefault('_controller', '\\Drupal\\language_hierarchy\\Controller\\ConfigTranslationController::itemPage');
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// Come after field_ui.
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-110,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | property | The mapper plugin discovery service. | |
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:: |
|
RouteSubscriber:: |
public | function | Constructs a new RouteSubscriber. | |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |