You are here

public function WebformRequest::getCurrentWebform in Webform 8.5

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

Get webform associated with the current request.

Return value

\Drupal\webform\WebformInterface|null The current request's webform.

Overrides WebformRequestInterface::getCurrentWebform

2 calls to WebformRequest::getCurrentWebform()
WebformRequest::getCurrentWebformUrl in src/WebformRequest.php
Get the URL for the current webform and source entity.
WebformRequest::getWebformEntities in src/WebformRequest.php
Get the webform and source entity for the current request.

File

src/WebformRequest.php, line 152

Class

WebformRequest
Handles webform requests.

Namespace

Drupal\webform

Code

public function getCurrentWebform() {
  $webform = $this->routeMatch
    ->getParameter('webform');
  if (is_string($webform)) {
    $webform = $this->entityTypeManager
      ->getStorage('webform')
      ->load($webform);
  }
  if ($webform) {
    return $webform;
  }
  $source_entity = static::getCurrentSourceEntity('webform');
  if ($source_entity && ($source_entity_webform = $this->webformEntityReferenceManager
    ->getWebform($source_entity))) {
    return $source_entity_webform;
  }
  return NULL;
}