function RouteSubscriber::getEntityRenderRoute

Same name in other branches
  1. 4.x src/Routing/RouteSubscriber.php \Drupal\devel\Routing\RouteSubscriber::getEntityRenderRoute()

Gets the entity render 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::getEntityRenderRoute()
RouteSubscriber::alterRoutes in src/Routing/RouteSubscriber.php
Alters existing routes for a specific collection.

File

src/Routing/RouteSubscriber.php, line 156

Class

RouteSubscriber
Subscriber for Devel routes.

Namespace

Drupal\devel\Routing

Code

protected function getEntityRenderRoute(EntityTypeInterface $entity_type) : ?Route {
    if ($devel_render = $entity_type->getLinkTemplate('devel-render')) {
        $route = (new Route($devel_render))->addDefaults([
            '_controller' => EntityDebugController::class . '::entityRender',
            '_title' => 'Devel Render',
        ])
            ->addRequirements([
            '_permission' => 'access devel information',
        ])
            ->setOption('_admin_route', TRUE)
            ->setOption('_devel_entity_type_id', $entity_type->id());
        if (($parameters = $this->getRouteParameters($entity_type, 'canonical')) !== []) {
            $route->setOption('parameters', $parameters);
        }
        return $route;
    }
    return NULL;
}