You are here

public function WebformRevisionsRequest::getBaseRouteName in Config Entity Revisions 8.2

Same name and namespace in other branches
  1. 8 modules/webform_revisions/src/WebformRevisionsRequest.php \Drupal\webform_revisions\WebformRevisionsRequest::getBaseRouteName()
  2. 1.x modules/webform_revisions/src/WebformRevisionsRequest.php \Drupal\webform_revisions\WebformRevisionsRequest::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 WebformRequest::getBaseRouteName

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

File

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

Class

WebformRevisionsRequest
Handles webform requests.

Namespace

Drupal\webform_revisions

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';
  }
}