protected function EntityModerationRouteProvider::getLatestVersionRoute in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/Routing/EntityModerationRouteProvider.php \Drupal\workbench_moderation\Routing\EntityModerationRouteProvider::getLatestVersionRoute()
Gets the moderation-form 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 EntityModerationRouteProvider::getLatestVersionRoute()
- EntityModerationRouteProvider::getRoutes in src/Routing/ EntityModerationRouteProvider.php 
- Provides routes for entities.
File
- src/Routing/ EntityModerationRouteProvider.php, line 71 
Class
- EntityModerationRouteProvider
- Provides the following routes:.
Namespace
Drupal\workbench_moderation\RoutingCode
protected function getLatestVersionRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('latest-version') && $entity_type
    ->hasViewBuilderClass()) {
    $entity_type_id = $entity_type
      ->id();
    $route = new Route($entity_type
      ->getLinkTemplate('latest-version'));
    $route
      ->addDefaults([
      '_entity_view' => "{$entity_type_id}.full",
      '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
    ])
      ->setRequirement('_entity_access', "{$entity_type_id}.view")
      ->setRequirement('_permission', 'view latest version,view any unpublished content')
      ->setRequirement('_workbench_moderation_latest_version', 'TRUE')
      ->setOption('_workbench_moderation_entity_type', $entity_type_id)
      ->setOption('parameters', [
      $entity_type_id => [
        'type' => 'entity:' . $entity_type_id,
        'load_forward_revision' => 1,
      ],
    ]);
    // Entity types with serial IDs can specify this in their route
    // requirements, improving the matching process.
    if ($this
      ->getEntityTypeIdKeyType($entity_type) === 'integer') {
      $route
        ->setRequirement($entity_type_id, '\\d+');
    }
    return $route;
  }
}