You are here

public function LDAPAuthorizationProvider::buildRowForm in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_authorization/src/Plugin/authorization/Provider/LDAPAuthorizationProvider.php \Drupal\ldap_authorization\Plugin\authorization\Provider\LDAPAuthorizationProvider::buildRowForm()

Builds the authorization form row.

Return array.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

int $index: The row number of the mapping.

Overrides ConfigurableAuthorizationPluginBase::buildRowForm

File

ldap_authorization/src/Plugin/authorization/Provider/LDAPAuthorizationProvider.php, line 197

Class

LDAPAuthorizationProvider
The LDAP authorization provider for authorization module.

Namespace

Drupal\ldap_authorization\Plugin\authorization\Provider

Code

public function buildRowForm(array $form, FormStateInterface $form_state, $index = 0) : array {
  $row = [];

  /** @var \Drupal\authorization\Entity\AuthorizationProfile $profile */
  $profile = $this->configuration['profile'];
  $mappings = $profile
    ->getProviderMappings();
  $row['query'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('LDAP query'),
    '#maxlength' => 254,
    '#default_value' => $mappings[$index]['query'] ?? NULL,
  ];
  $row['is_regex'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Is this query a regular expression?'),
    '#description' => $this
      ->t('Example (note the "i" for case-insensitive): %example', [
      '%example' => new FormattableMarkup('<code>/^memberOf=staff/i</code>', []),
    ]),
    '#default_value' => $mappings[$index]['is_regex'] ?? NULL,
  ];
  return $row;
}