You are here

protected function PullForm::getSelectOptions in Entity Share 8.3

Helper function.

Parameters

string $field: The form field key.

Return value

string[] An array of options for a given select list.

1 call to PullForm::getSelectOptions()
PullForm::buildSelectElement in modules/entity_share_client/src/Form/PullForm.php
Builds a required select element, disabled if only one option exists.

File

modules/entity_share_client/src/Form/PullForm.php, line 331

Class

PullForm
Form controller to pull entities.

Namespace

Drupal\entity_share_client\Form

Code

protected function getSelectOptions(string $field) {
  $options = [];
  switch ($field) {
    case 'remote':

      // An array of remote websites.
      foreach ($this->remoteWebsites as $id => $remote_website) {
        $options[$id] = $remote_website
          ->label();
      }
      break;
    case 'channel':

      // An array of remote channels.
      foreach ($this->channelsInfos as $channel_id => $channel_infos) {
        $options[$channel_id] = $channel_infos['label'];
      }
      break;
    case 'import_config':

      // An array of import configs.
      $import_configs = $this->entityTypeManager
        ->getStorage('import_config')
        ->loadMultiple();
      foreach ($import_configs as $import_config) {
        $options[$import_config
          ->id()] = $import_config
          ->label();
      }
      break;
  }
  return $options;
}