You are here

public function WebformRequest::getBaseRouteName in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformRequest.php \Drupal\webform\WebformRequest::getBaseRouteName()

Get the base route name 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

string If the source entity has a webform attached, 'entity.{entity_type_id}' or just 'entity'.

Overrides WebformRequestInterface::getBaseRouteName

1 call to WebformRequest::getBaseRouteName()
WebformRequest::getRouteName in src/WebformRequest.php
Get the route name for a form/submission and source entity.

File

src/WebformRequest.php, line 283

Class

WebformRequest
Handles webform requests.

Namespace

Drupal\webform

Code

public function getBaseRouteName(EntityInterface $webform_entity, EntityInterface $source_entity = NULL) {
  if ($webform_entity instanceof WebformSubmissionInterface) {
    $webform = $webform_entity
      ->getWebform();
  }
  elseif ($webform_entity instanceof WebformInterface) {
    $webform = $webform_entity;
  }
  else {
    throw new \InvalidArgumentException('Webform entity');
  }
  if (static::isValidSourceEntity($webform, $source_entity)) {
    return 'entity.' . $source_entity
      ->getEntityTypeId();
  }
  else {
    return 'entity';
  }
}