You are here

public function PetHtmlRouteProvider::getRoutes in Previewable email templates 8.3

Same name and namespace in other branches
  1. 8.4 src/PetHtmlRouteProvider.php \Drupal\pet\PetHtmlRouteProvider::getRoutes()
  2. 8 src/PetHtmlRouteProvider.php \Drupal\pet\PetHtmlRouteProvider::getRoutes()

Provides routes for entities.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type

Return value

\Symfony\Component\Routing\RouteCollection|\Symfony\Component\Routing\Route[] Returns a route collection or an array of routes keyed by name, like route_callbacks inside 'routing.yml' files.

Overrides DefaultHtmlRouteProvider::getRoutes

File

src/PetHtmlRouteProvider.php, line 20

Class

PetHtmlRouteProvider
Provides routes for pet entities.

Namespace

Drupal\pet

Code

public function getRoutes(EntityTypeInterface $entity_type) {
  $collection = parent::getRoutes($entity_type);
  $entity_type_id = $entity_type
    ->id();

  // It seems that by default, you need "administer pet entities" to view
  // the collection list.
  $collection
    ->get("entity.{$entity_type_id}.collection")
    ->setRequirement('_permission', 'view pet entity');
  if ($history_route = $this
    ->getHistoryRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.version_history", $history_route);
  }
  if ($preview_route = $this
    ->getPreviewRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.preview", $preview_route);
  }
  if ($revision_route = $this
    ->getRevisionRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.revision", $revision_route);
  }
  if (\Drupal::moduleHandler()
    ->moduleExists('diff')) {
    if ($revisions_diff_route = $this
      ->getRevisionsDiffRoute($entity_type)) {
      $collection
        ->add("entity.{$entity_type_id}.revisions_diff", $revisions_diff_route);
    }
  }
  if ($revert_route = $this
    ->getRevisionRevertRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.revision_revert_confirm", $revert_route);
  }
  if ($delete_route = $this
    ->getRevisionDeleteRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.revision_delete_confirm", $delete_route);
  }
  if ($translation_route = $this
    ->getRevisionTranslationRevertRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.revision_revert_translation_confirm", $translation_route);
  }
  if ($settings_form_route = $this
    ->getSettingsFormRoute($entity_type)) {
    $collection
      ->add("{$entity_type_id}.settings", $settings_form_route);
  }
  return $collection;
}