function RouteSubscriber::getEntityLoadRoute
Same name in other branches
- 4.x src/Routing/RouteSubscriber.php \Drupal\devel\Routing\RouteSubscriber::getEntityLoadRoute()
Gets the entity load route.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.
Return value
\Symfony\Component\Routing\Route|null The generated route, if available.
1 call to RouteSubscriber::getEntityLoadRoute()
- RouteSubscriber::alterRoutes in src/
Routing/ RouteSubscriber.php - Alters existing routes for a specific collection.
File
-
src/
Routing/ RouteSubscriber.php, line 86
Class
- RouteSubscriber
- Subscriber for Devel routes.
Namespace
Drupal\devel\RoutingCode
protected function getEntityLoadRoute(EntityTypeInterface $entity_type) : ?Route {
if ($devel_load = $entity_type->getLinkTemplate('devel-load')) {
$route = (new Route($devel_load))->addDefaults([
'_controller' => EntityDebugController::class . '::entityLoad',
'_title' => 'Devel Load',
])
->addRequirements([
'_permission' => 'access devel information',
])
->setOption('_admin_route', TRUE)
->setOption('_devel_entity_type_id', $entity_type->id());
// Set the parameters of the new route using the existing 'edit-form'
// route parameters. If there are none (for example, where Devel creates
// a link for entities with no edit-form) then we need to set the basic
// parameter [entity_type_id => [type => 'entity:entity_type_id']].
// @see https://gitlab.com/drupalspoons/devel/-/issues/377
$parameters = $this->getRouteParameters($entity_type, 'edit-form') !== [] ? $this->getRouteParameters($entity_type, 'edit-form') : [
$entity_type->id() => [
'type' => 'entity:' . $entity_type->id(),
],
];
$route->setOption('parameters', $parameters);
return $route;
}
return NULL;
}