trait VariableAttributeCustomization in Lightweight Directory Access Protocol (LDAP) 8.3
Same name and namespace in other branches
- 8.4 ldap_query/src/Plugin/views/VariableAttributeCustomization.php \Drupal\ldap_query\Plugin\views\VariableAttributeCustomization
Collates the variable attribute customization to apply it to more than one.
Hierarchy
- trait \Drupal\ldap_query\Plugin\views\VariableAttributeCustomization
4 files declare their use of VariableAttributeCustomization
- LdapVariableAttribute.php in ldap_query/
src/ Plugin/ views/ filter/ LdapVariableAttribute.php - LdapVariableAttribute.php in ldap_query/
src/ Plugin/ views/ sort/ LdapVariableAttribute.php - LdapVariableAttribute.php in ldap_query/
src/ Plugin/ views/ argument/ LdapVariableAttribute.php - LdapVariableAttribute.php in ldap_query/
src/ Plugin/ views/ field/ LdapVariableAttribute.php
File
- ldap_query/
src/ Plugin/ views/ VariableAttributeCustomization.php, line 11
Namespace
Drupal\ldap_query\Plugin\viewsView source
trait VariableAttributeCustomization {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['attribute_name'] = [
'default' => '',
];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$queryOptions = $this->view
->getDisplay()
->getOption('query')['options'];
if (!isset($queryOptions['query_id']) || empty($queryOptions['query_id'])) {
$form['attribute_name'] = [
'#markup' => 'You must select a valid LDAP search (Advanced => Query settings)',
];
return;
}
$controller = new QueryController($queryOptions['query_id']);
$controller
->execute();
$options = $controller
->availableFields();
$form['attribute_name'] = [
'#type' => 'select',
'#title' => t('Attribute name'),
'#description' => t('The attribute name from LDAP response'),
'#options' => $options,
'#default_value' => $this->options['attribute_name'],
'#required' => TRUE,
];
}
/**
* Called to add the field to a query.
*/
public function query() {
$this->realField = $this->options['attribute_name'];
parent::query();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
VariableAttributeCustomization:: |
public | function | 1 | |
VariableAttributeCustomization:: |
protected | function | ||
VariableAttributeCustomization:: |
public | function | Called to add the field to a query. | 2 |