EntityTypeModerationRouteProvider::getModerationFormRoute

protected EntityTypeModerationRouteProvider::getModerationFormRoute(EntityTypeInterface $entity_type)

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.

File

core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php, line 38

Class

EntityTypeModerationRouteProvider
Provides the moderation configuration routes for config entities.

Namespace

Drupal\content_moderation\Routing

Code

protected function getModerationFormRoute(EntityTypeInterface $entity_type) {
  if ($entity_type->hasLinkTemplate('moderation-form') && $entity_type->getFormClass('moderation')) {
    $entity_type_id = $entity_type->id();

    $route = new Route($entity_type->getLinkTemplate('moderation-form'));

    // @todo Come up with a new permission.
    $route
    ->setDefaults([
      '_entity_form' => "{$entity_type_id}.moderation",
      '_title' => 'Moderation',
    ])
      ->setRequirement('_permission', 'administer moderation states')
      ->setOption('parameters', [
        $entity_type_id => ['type' => 'entity:' . $entity_type_id],
      ]);

    return $route;
  }
}
doc_Drupal
2016-10-29 09:08:40
Comments
Leave a Comment

Please login to continue.