public function SwitchForm::getDomainOptions in Domain Access 8
Gets the available domain list for the form user.
Return value
array An array of select options.
1 call to SwitchForm::getDomainOptions()
- SwitchForm::addSwitchFields in domain_config_ui/src/ Form/ SwitchForm.php 
- Helper to add switch fields to form.
File
- domain_config_ui/src/ Form/ SwitchForm.php, line 216 
Class
- SwitchForm
- Class SwitchForm.
Namespace
Drupal\domain_config_ui\FormCode
public function getDomainOptions() {
  $domains = $this->domainStorage
    ->loadMultipleSorted();
  $options = [];
  foreach ($domains as $domain) {
    // If the user cannot view the domain, then don't show in the list.
    // View here is sufficient, because it means the user is assigned to the
    // domain. We have already checked for the ability to use this form.
    $access = $this->accessHandler
      ->checkAccess($domain, 'view');
    if ($access
      ->isAllowed()) {
      $options[$domain
        ->id()] = $domain
        ->label();
    }
  }
  // The user must have permission to set the default value.
  if ($this
    ->currentUser()
    ->hasPermission('set default domain configuration')) {
    $options = array_merge([
      '' => $this
        ->t('All Domains'),
    ], $options);
  }
  return $options;
}