You are here

protected function WebformEntityElements::getConfigurationOptions in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_webform/src/Plugin/SalesforceMappingField/WebformEntityElements.php \Drupal\salesforce_webform\Plugin\SalesforceMappingField\WebformEntityElements::getConfigurationOptions()

Form options helper.

1 call to WebformEntityElements::getConfigurationOptions()
WebformEntityElements::buildConfigurationForm in modules/salesforce_webform/src/Plugin/SalesforceMappingField/WebformEntityElements.php
Form constructor.

File

modules/salesforce_webform/src/Plugin/SalesforceMappingField/WebformEntityElements.php, line 98

Class

WebformEntityElements
Adapter for Webform elements.

Namespace

Drupal\salesforce_webform\Plugin\SalesforceMappingField

Code

protected function getConfigurationOptions($mapping) {

  /** @var \Drupal\webform\Entity\Webform $webform */
  $webform = $this->entityTypeManager
    ->getStorage('webform')
    ->load($mapping
    ->get('drupal_bundle'));
  $webform_elements = $webform
    ->getElementsInitializedFlattenedAndHasValue();
  if (empty($webform_elements)) {
    return;
  }
  $options = [];
  foreach ($webform_elements as $element_id => $element) {

    // All webform elements that are entity references are named in the form:
    // webform_entity_[elementtype]. Except autocomplete which is missing
    // "webform".
    if (stripos($element['#type'], 'webform_entity') !== FALSE || $element['#type'] == 'entity_autocomplete') {
      $options[$element_id] = $element['#title'];
    }
  }
  if (empty($options)) {
    return;
  }
  asort($options);
  return $options;
}