You are here

public function Webform::getElement in Webform 8.5

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

Get a webform's initialized element.

Parameters

string $key: The element's key.

bool $include_children: Include initialized children.

Return value

array|null An associative array containing an initialized element.

Overrides WebformInterface::getElement

1 call to Webform::getElement()
Webform::applyVariant in src/Entity/Webform.php
Apply webform variant.

File

src/Entity/Webform.php, line 1827

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function getElement($key, $include_children = FALSE) {
  $elements_flattened = $this
    ->getElementsInitializedAndFlattened();
  $element = isset($elements_flattened[$key]) ? $elements_flattened[$key] : NULL;
  if ($element && $include_children) {
    $elements = $this
      ->getElementsInitialized();
    return NestedArray::getValue($elements, $element['#webform_parents']);
  }
  else {
    return $element;
  }
}