class RouteSubscriber in Display Suite 8.3
Same name in this branch
- 8.3 src/Routing/RouteSubscriber.php \Drupal\ds\Routing\RouteSubscriber
- 8.3 modules/ds_devel/src/Routing/RouteSubscriber.php \Drupal\ds_devel\Routing\RouteSubscriber
- 8.3 modules/ds_extras/src/EventSubscriber/RouteSubscriber.php \Drupal\ds_extras\EventSubscriber\RouteSubscriber
Same name and namespace in other branches
- 8.4 modules/ds_devel/src/Routing/RouteSubscriber.php \Drupal\ds_devel\Routing\RouteSubscriber
- 8.2 modules/ds_devel/src/Routing/RouteSubscriber.php \Drupal\ds_devel\Routing\RouteSubscriber
Subscriber for Devel routes.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\ds_devel\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
- ds_devel.services.yml in modules/
ds_devel/ ds_devel.services.yml - modules/ds_devel/ds_devel.services.yml
1 service uses RouteSubscriber
- ds_devel.route_subscriber in modules/
ds_devel/ ds_devel.services.yml - Drupal\ds_devel\Routing\RouteSubscriber
File
- modules/
ds_devel/ src/ Routing/ RouteSubscriber.php, line 14
Namespace
Drupal\ds_devel\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* The entity manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new RouteSubscriber object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->hasLinkTemplate('devel-markup')) {
$options = [
'_admin_route' => TRUE,
'_devel_entity_type_id' => $entity_type_id,
'parameters' => [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
],
];
if ($devel_render = $entity_type
->getLinkTemplate('devel-markup')) {
$route = new Route($devel_render, [
'_controller' => '\\Drupal\\ds_devel\\Controller\\DsDevelController::entityMarkup',
'_title' => 'Markup',
], [
'_permission' => 'access devel information',
], $options);
$collection
->add("entity.{$entity_type_id}.devel_markup", $route);
}
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
100,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | property | The entity manager 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 object. | |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |