You are here

public function YamlFormRequest::getBaseRouteName in YAML Form 8

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

Parameters

\Drupal\Core\Entity\EntityInterface $yamlform_entity: A form or form submission.

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

Return value

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

Overrides YamlFormRequestInterface::getBaseRouteName

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

File

src/YamlFormRequest.php, line 160

Class

YamlFormRequest
Handles form requests.

Namespace

Drupal\yamlform

Code

public function getBaseRouteName(EntityInterface $yamlform_entity, EntityInterface $source_entity = NULL) {
  if ($yamlform_entity instanceof YamlFormSubmissionInterface) {
    $yamlform = $yamlform_entity
      ->getYamlForm();
  }
  elseif ($yamlform_entity instanceof YamlFormInterface) {
    $yamlform = $yamlform_entity;
  }
  else {
    throw new \InvalidArgumentException('Form entity');
  }
  if (self::isValidSourceEntity($yamlform, $source_entity)) {
    return 'entity.' . $source_entity
      ->getEntityTypeId();
  }
  else {
    return 'entity';
  }
}