protected function RouteSubscriber::getPreviewRenderRoute in View Modes Display 8.2
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::getPreviewRenderRoute()
- RouteSubscriber::alterRoutes in src/
Routing/ RouteSubscriber.php - Alters existing routes for a specific collection.
File
- src/
Routing/ RouteSubscriber.php, line 101
Class
- RouteSubscriber
- Subscriber for View Mode Display routes.
Namespace
Drupal\view_modes_display\RoutingCode
protected function getPreviewRenderRoute(EntityTypeInterface $entity_type) {
if ($link_template = $entity_type
->getLinkTemplate('vmd-preview-list')) {
$entity_type_id = $entity_type
->id();
$route = new Route($link_template);
$route
->addDefaults([
'_controller' => '\\Drupal\\view_modes_display\\Controller\\PreviewController::previewEntity',
'_title' => 'View Mode Preview',
'entity_type' => $entity_type_id,
])
->addRequirements([
'_permission' => 'preview view modes',
])
->setOption('parameters', [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
]);
return $route;
}
}