You are here

public function WebformRevisionsRequest::getRouteParameters in Config Entity Revisions 8

Same name and namespace in other branches
  1. 8.2 modules/webform_revisions/src/WebformRevisionsRequest.php \Drupal\webform_revisions\WebformRevisionsRequest::getRouteParameters()
  2. 1.x modules/webform_revisions/src/WebformRevisionsRequest.php \Drupal\webform_revisions\WebformRevisionsRequest::getRouteParameters()

Get the route parameters for a form/submission and source entity.

Parameters

\Drupal\Core\Entity\EntityInterface $webform_entity: A webform or webform submission.

\Drupal\Core\Entity\EntityInterface|null $source_entity: A webform submission's source entity.

Return value

array An array of route parameters.

Overrides WebformRequest::getRouteParameters

1 call to WebformRevisionsRequest::getRouteParameters()
WebformRevisionsRequest::getUrl in modules/webform_revisions/src/WebformRevisionsRequest.php
Get the URL for a form/submission and source entity.

File

modules/webform_revisions/src/WebformRevisionsRequest.php, line 259

Class

WebformRevisionsRequest
Handles webform requests.

Namespace

Drupal\webform_revisions

Code

public function getRouteParameters(EntityInterface $webform_entity, EntityInterface $source_entity = NULL) {
  if (!$this
    ->hasSourceEntityWebformRoutes($source_entity)) {
    $source_entity = NULL;
  }
  if (static::isValidSourceEntity($webform_entity, $source_entity)) {
    if ($webform_entity instanceof WebformSubmissionInterface) {
      return [
        'webform_submission' => $webform_entity
          ->id(),
        $source_entity
          ->getEntityTypeId() => $source_entity
          ->id(),
      ];
    }
    else {
      return [
        $source_entity
          ->getEntityTypeId() => $source_entity
          ->id(),
      ];
    }
  }
  elseif ($webform_entity instanceof WebformSubmissionInterface) {
    return [
      'webform_submission' => $webform_entity
        ->id(),
      'webform' => $webform_entity
        ->getWebform()
        ->id(),
    ];
  }
  else {
    return [
      $webform_entity
        ->getEntityTypeId() => $webform_entity
        ->id(),
    ];
  }
}