protected function WebformTranslationConfigManager::buildConfigWebformFormElements in Webform 6.x
Build config webform form elements.
Parameters
array $element: The Webform element.
array $translation_element: The Webform element's translated properties.
array $source_element: The Webform element's source properties.
array $parents: The Webform element's parents.
Return value
array A render array containing config webform form elements.
2 calls to WebformTranslationConfigManager::buildConfigWebformFormElements()
- WebformTranslationConfigManager::alterConfigWebformFormElements in src/
WebformTranslationConfigManager.php - Alter the webform configuration form elements.
- WebformTranslationConfigManager::buildConfigWebformFormCompositePropertyElement in src/
WebformTranslationConfigManager.php - Build config webform form composite property element.
File
- src/
WebformTranslationConfigManager.php, line 418
Class
- WebformTranslationConfigManager
- Defines a class to translate webform config.
Namespace
Drupal\webformCode
protected function buildConfigWebformFormElements(array $element, array $translation_element, array $source_element, array $parents) {
$webform_element = $this->elementManager
->getElementInstance($element);
$element_properties = $this
->getWebformElementProperties($webform_element
->getPluginId());
$elements = [
'#type' => 'details',
'#title' => $this
->t('@title (@type)', [
'@title' => $element['#title'],
'@type' => $webform_element
->getPluginId(),
]),
'#open' => TRUE,
];
foreach ($translation_element as $property_name => $property_value) {
$property_key = ltrim($property_name, '#');
$property_parents = array_merge($parents, [
$property_key,
]);
$property_type = isset($element_properties[$property_key]) && isset($element_properties[$property_key]['#type']) ? $element_properties[$property_key]['#type'] : NULL;
// NOTE: It is possible that all the below code could be moved into
// the WebformElement plugin but this would create more abstraction.
// For now, it is easier to keep all the logic in this one class/service.
if (is_array($property_value) && !WebformArrayHelper::isMultidimensional($property_value)) {
// Options.
$elements[$property_key] = $this
->buildConfigWebformFormOptionsPropertyElement($element, $translation_element, $source_element, $property_parents);
}
elseif ($property_type === 'webform_image_select_element_images' && $property_name === '#images') {
// Images.
$elements[$property_key] = $this
->buildConfigWebformFormImageSelectPropertyElement($element, $translation_element, $source_element, $property_parents);
}
elseif ($property_type === 'webform_element_composite' && $property_name === '#element') {
// Composite.
$elements[$property_key] = $this
->buildConfigWebformFormCompositePropertyElement($element, $translation_element, $source_element, $property_parents);
}
else {
// Default.
$elements[$property_key] = $this
->buildConfigWebformFormDefaultPropertyElement($element, $translation_element, $source_element, $property_parents);
}
}
return $elements;
}