You are here

public function WebformDevelSchema::getElements in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_devel/src/WebformDevelSchema.php \Drupal\webform_devel\WebformDevelSchema::getElements()

Get a webform's scheme elements.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

Return value

array An associative containing a webform's scheme elements.

Overrides WebformDevelSchemaInterface::getElements

File

modules/webform_devel/src/WebformDevelSchema.php, line 82

Class

WebformDevelSchema
Provides a webform schema generator.

Namespace

Drupal\webform_devel

Code

public function getElements(WebformInterface $webform) {
  $records = [];
  $elements = $webform
    ->getElementsInitializedFlattenedAndHasValue();
  foreach ($elements as $element_key => $element) {
    $element_plugin = $this->elementManager
      ->getElementInstance($element);
    $records[$element_key] = $this
      ->getElement($element_key, $element);
    if ($element_plugin instanceof WebformCompositeBase) {
      $composite_elements = $element_plugin
        ->getInitializedCompositeElement($element);
      foreach ($composite_elements as $composite_element_key => $composite_element) {
        $records["{$element_key}.{$composite_element_key}"] = $this
          ->getElement("{$element_key}.{$composite_element_key}", $composite_element);
      }
    }
  }
  return $records;
}