You are here

public function WebformComposite::getElementsDecoded in Webform Composite Tools 8

Get composite elements decoded as an associative array.

Return value

array|bool Elements as an associative array. Returns FALSE for invalid element YAML.

Overrides WebformCompositeInterface::getElementsDecoded

File

src/Entity/WebformComposite.php, line 96

Class

WebformComposite
Defines the Webform Composite entity.

Namespace

Drupal\webform_composite\Entity

Code

public function getElementsDecoded() {
  if (!isset($this->elementsDecoded)) {

    // Decode elements from YAML.
    $elements = Yaml::decode($this->elements);

    // Since YAML supports simple values.
    $elements = is_array($elements) ? $elements : [];
    foreach ($elements as &$element) {
      if (isset($element["#states"])) {

        // Strip element states data. This causes unexpected behavior.
        unset($element["#states"]);
      }
    }
    $this->elementsDecoded = $elements;
  }
  return $this->elementsDecoded;
}