You are here

public function WebformRequest::getRouteParameters in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformRequest.php \Drupal\webform\WebformRequest::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 WebformRequestInterface::getRouteParameters

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

File

src/WebformRequest.php, line 253

Class

WebformRequest
Handles webform requests.

Namespace

Drupal\webform

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(),
    ];
  }
}