You are here

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

Same name and namespace in other branches
  1. 8.4 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 39

Class

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

Namespace

Drupal\ldap_user\Form

Code

public function __construct(ConfigFactoryInterface $config_factory, ServerFactory $server_factory, CacheBackendInterface $cache, ModuleHandler $module_handler) {
  parent::__construct($config_factory);
  $this->serverFactory = $server_factory;
  $this->cache = $cache;
  $this->moduleHandler = $module_handler;
  $ldap_servers = $this->serverFactory
    ->getEnabledServers();
  if ($ldap_servers) {
    foreach ($ldap_servers as $sid => $ldap_server) {

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