protected function PreviewLinkRouteProvider::getGeneratePreviewLinkRoute in Preview Link 8
Same name and namespace in other branches
- 2.x src/Routing/PreviewLinkRouteProvider.php \Drupal\preview_link\Routing\PreviewLinkRouteProvider::getGeneratePreviewLinkRoute()
- 2.0.x src/Routing/PreviewLinkRouteProvider.php \Drupal\preview_link\Routing\PreviewLinkRouteProvider::getGeneratePreviewLinkRoute()
Gets the route for generating and viewing preview links for this entity.
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 PreviewLinkRouteProvider::getGeneratePreviewLinkRoute()
- PreviewLinkRouteProvider::getRoutes in src/
Routing/ PreviewLinkRouteProvider.php - Provides routes for entities.
File
- src/
Routing/ PreviewLinkRouteProvider.php, line 43
Class
- PreviewLinkRouteProvider
- Preview Link route provider.
Namespace
Drupal\preview_link\RoutingCode
protected function getGeneratePreviewLinkRoute(EntityTypeInterface $entity_type) {
if (!$entity_type
->hasLinkTemplate('canonical')) {
return NULL;
}
$entity_type_id = $entity_type
->id();
$route = new Route($entity_type
->getLinkTemplate('canonical') . '/generate-preview-link');
$route
->setDefaults([
'_entity_form' => "preview_link.preview_link",
'_title' => 'Preview',
])
->setRequirement('_permission', 'generate preview links')
->setRequirement('_access_preview_enabled', 'TRUE')
->setOption('preview_link.entity_type_id', $entity_type_id)
->setOption('parameters', [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
]);
return $route;
}