public function DebuggingReviewForm::buildForm in Lightweight Directory Access Protocol (LDAP) 8.4
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- ldap_servers/
src/ Form/ DebuggingReviewForm.php, line 96
Class
- DebuggingReviewForm
- Form to allow for debugging review.
Namespace
Drupal\ldap_servers\FormCode
public function buildForm(array $form, FormStateInterface $form_state) : array {
$form['title'] = [
'#markup' => '<h1>' . $this
->t('LDAP Debugging Review') . '</h1>',
];
if (!extension_loaded('ldap')) {
$this
->messenger()
->addError($this
->t('PHP LDAP extension not loaded.'));
}
else {
$form['heading_modules'] = [
'#markup' => '<h2>' . $this
->t('PHP LDAP module') . '</h2>',
];
$form['modules'] = [
'#markup' => '<pre>' . Yaml::encode($this
->parsePhpModules()['ldap']) . '</pre>',
];
}
$form['heading_ldap'] = [
'#markup' => '<h2>' . $this
->t('Drupal LDAP modules') . '</h2>',
];
if ($this->moduleHandler
->moduleExists('ldap_user')) {
$form['config_users'] = [
'#markup' => '<h3>' . $this
->t('The LDAP user configuration') . '</h3>' . $this
->printConfig('ldap_user.settings'),
];
}
$user_register = $this
->config('user.settings')
->get('register');
$form['config_users_registration'] = [
'#markup' => $this
->t('Currently active Drupal user registration setting: @setting', [
'@setting' => $user_register,
]),
];
if ($this->moduleHandler
->moduleExists('ldap_authentication')) {
$form['config_authentication'] = [
'#markup' => '<h3>' . $this
->t('The LDAP authentication configuration') . '</h3>' . $this
->printConfig('ldap_authentication.settings'),
];
}
$form['config_help'] = [
'#markup' => '<h3>' . $this
->t('The LDAP help configuration') . '</h3>' . $this
->printConfig('ldap_servers.settings'),
];
$form['heading_servers'] = [
'#markup' => '<h2>' . $this
->t('Drupal LDAP servers') . '</h2>',
];
$storage = $this->entityTypeManager
->getStorage('ldap_server');
$servers = $storage
->getQuery()
->execute();
foreach ($storage
->loadMultiple($servers) as $sid => $server) {
/** @var \Drupal\ldap_servers\Entity\Server $server */
$form['config_server_' . $sid] = [
'#markup' => '<h3>' . $this
->t('Server @name:', [
'@name' => $server
->label(),
]) . '</h3>' . $this
->printConfig('ldap_servers.server.' . $sid),
];
}
if ($this->moduleHandler
->moduleExists('authorization') && $this->moduleHandler
->moduleExists('ldap_authorization')) {
$form['heading_profiles'] = [
'#markup' => '<h2>' . $this
->t('Configured authorization profiles') . '</h2>',
];
$profiles = $this->entityTypeManager
->getStorage('authorization_profile')
->getQuery()
->execute();
foreach ($profiles as $profile) {
$form['authorization_profile_' . $profile] = [
'#markup' => '<h3>' . $this
->t('Profile @name:', [
'@name' => $profile,
]) . '</h3>' . $this
->printConfig('authorization.authorization_profile.' . $profile),
];
}
}
if ($this->moduleHandler
->moduleExists('ldap_query')) {
$form['heading_queries'] = [
'#markup' => '<h2>' . $this
->t('Configured LDAP queries') . '</h2>',
];
$queries_found = $this->entityTypeManager
->getStorage('ldap_query_entity')
->getQuery()
->execute();
foreach ($this->entityTypeManager
->getStorage('ldap_query_entity')
->loadMultiple($queries_found) as $query) {
/** @var \Drupal\ldap_query\Entity\QueryEntity $query */
$form['query_' . $query
->id()] = [
'#markup' => '<h3>' . $this
->t('Query @name:', [
'@name' => $query
->label(),
]) . '</h3>' . $this
->printConfig('ldap_query.ldap_query_entity.' . $query
->id()),
];
}
}
return $form;
}