public function WebformTranslationManager::getBaseElements in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformTranslationManager.php \Drupal\webform\WebformTranslationManager::getBaseElements()
Get base webform elements for the site's default language.
Parameters
\Drupal\webform\WebformInterface $webform: A webform.
Return value
array Base webform elements as a flattened associative array.
Overrides WebformTranslationManagerInterface::getBaseElements
1 call to WebformTranslationManager::getBaseElements()
- WebformTranslationManager::getSourceElements in src/
WebformTranslationManager.php - Get flattened associative array of translated element properties.
File
- src/
WebformTranslationManager.php, line 143
Class
- WebformTranslationManager
- Defines a class to translate webform elements.
Namespace
Drupal\webformCode
public function getBaseElements(WebformInterface $webform) {
$default_langcode = $this
->getOriginalLangcode($webform) ?: $this->languageManager
->getDefaultLanguage()
->getId();
$config_elements = $this
->getElements($webform, $default_langcode);
$elements = WebformElementHelper::getFlattened($config_elements);
foreach ($elements as $element_key => &$element) {
// Always include composite element's default '#{element}__title'.
$element_plugin = $this->elementManager
->getElementInstance($element);
if ($element_plugin instanceof WebformCompositeBase) {
$composite_elements = $element_plugin
->getCompositeElements();
foreach ($composite_elements as $composite_key => $composite_element) {
$property_key = $composite_key . '__title';
if (empty($element["#{$property_key}"])) {
$element["#{$property_key}"] = $element_plugin
->getDefaultProperty($property_key);
}
}
}
$this
->removeUnTranslatablePropertiesFromElement($element);
if (empty($element)) {
unset($elements[$element_key]);
}
}
return $elements;
}