public function WebformDevelSchema::getElements in Webform 6.x
Same name and namespace in other branches
- 8.5 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 94
Class
- WebformDevelSchema
- Provides a webform schema generator.
Namespace
Drupal\webform_develCode
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);
}
}
}
$field_definitions = $this->entityFieldManager
->getBaseFieldDefinitions('webform_submission');
foreach ($field_definitions as $field_name => $field_definition) {
$definition = $this
->getDefinition($field_definition);
unset($definition['options']);
$records[$field_name] = $definition;
}
return $records;
}