You are here

public function ViewRevisionsRequest::getRouteParameters in Config Entity Revisions 8

Same name and namespace in other branches
  1. 1.x modules/views_revisions/src/ViewsRevisionsRequest.php \Drupal\views_revisions\ViewRevisionsRequest::getRouteParameters()
1 call to ViewRevisionsRequest::getRouteParameters()
ViewRevisionsRequest::getUrl in modules/views_revisions/src/ViewsRevisionsRequest.php

File

modules/views_revisions/src/ViewsRevisionsRequest.php, line 259

Class

ViewRevisionsRequest
Handles view requests.

Namespace

Drupal\views_revisions

Code

public function getRouteParameters(EntityInterface $view_entity, EntityInterface $source_entity = NULL) {
  if (!$this
    ->hasSourceEntityViewRoutes($source_entity)) {
    $source_entity = NULL;
  }
  if (static::isValidSourceEntity($view_entity, $source_entity)) {
    if ($view_entity instanceof ViewSubmissionInterface) {
      return [
        'view_submission' => $view_entity
          ->id(),
        $source_entity
          ->getEntityTypeId() => $source_entity
          ->id(),
      ];
    }
    else {
      return [
        $source_entity
          ->getEntityTypeId() => $source_entity
          ->id(),
      ];
    }
  }
  elseif ($view_entity instanceof ViewSubmissionInterface) {
    return [
      'view_submission' => $view_entity
        ->id(),
      'view' => $view_entity
        ->getView()
        ->id(),
    ];
  }
  else {
    return [
      $view_entity
        ->getEntityTypeId() => $view_entity
        ->id(),
    ];
  }
}