You are here

protected function Webform::getContextWebform in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/Condition/Webform.php \Drupal\webform\Plugin\Condition\Webform::getContextWebform()

Gets the webform for a defined context.

Return value

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

1 call to Webform::getContextWebform()
Webform::evaluate in src/Plugin/Condition/Webform.php
Evaluates the condition and returns TRUE or FALSE accordingly.

File

src/Plugin/Condition/Webform.php, line 150

Class

Webform
Provides a 'Webform' condition.

Namespace

Drupal\webform\Plugin\Condition

Code

protected function getContextWebform() {
  if ($webform_submission = $this
    ->getContextValue('webform_submission')) {
    return $webform_submission
      ->getWebform();
  }
  if ($webform = $this
    ->getContextValue('webform')) {
    return $webform;
  }
  if ($node = $this
    ->getContextValue('node')) {
    if ($webform_target = $this->webformEntityReferenceManager
      ->getWebform($node)) {
      return $webform_target;
    }
  }
  return NULL;
}