You are here

public function LdapUserAdminForm::__construct in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_user/src/Form/LdapUserAdminForm.php \Drupal\ldap_user\Form\LdapUserAdminForm::__construct()

Constructs a \Drupal\system\ConfigFormBase object.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The factory for configuration objects.

Overrides ConfigFormBase::__construct

File

ldap_user/src/Form/LdapUserAdminForm.php, line 67

Class

LdapUserAdminForm
Provides the form to configure user configuration and field mapping.

Namespace

Drupal\ldap_user\Form

Code

public function __construct(ConfigFactoryInterface $config_factory, ModuleHandler $module_handler, EntityTypeManagerInterface $entity_type_manager) {
  parent::__construct($config_factory);
  $this->moduleHandler = $module_handler;
  $this->entityTypeManager = $entity_type_manager;
  $storage = $this->entityTypeManager
    ->getStorage('ldap_server');
  $ids = $storage
    ->getQuery()
    ->condition('status', 1)
    ->execute();
  foreach ($storage
    ->loadMultiple($ids) as $sid => $server) {

    /** @var \Drupal\ldap_servers\Entity\Server $server */
    $enabled = $server
      ->get('status') ? 'Enabled' : 'Disabled';
    $this->drupalAcctProvisionServerOptions[$sid] = $server
      ->label() . ' (' . $server
      ->get('address') . ') Status: ' . $enabled;
    $this->ldapEntryProvisionServerOptions[$sid] = $server
      ->label() . ' (' . $server
      ->get('address') . ') Status: ' . $enabled;
  }
  $this->drupalAcctProvisionServerOptions['none'] = $this
    ->t('None');
  $this->ldapEntryProvisionServerOptions['none'] = $this
    ->t('None');
  $this->currentConfig = $this
    ->config('ldap_user.settings');
}