private function LdapEntryProvisionSubscriber::fetchDrupalAccountField in Lightweight Directory Access Protocol (LDAP) 8.4
Fetch regular field token.
Parameters
string $attribute_name: Field name.
Return value
string Field data.
1 call to LdapEntryProvisionSubscriber::fetchDrupalAccountField()
- LdapEntryProvisionSubscriber::fetchDrupalAccountAttribute in ldap_user/
src/ EventSubscriber/ LdapEntryProvisionSubscriber.php - Fetch a single token.
File
- ldap_user/
src/ EventSubscriber/ LdapEntryProvisionSubscriber.php, line 348
Class
- LdapEntryProvisionSubscriber
- Event subscribers for creating and updating LDAP entries.
Namespace
Drupal\ldap_user\EventSubscriberCode
private function fetchDrupalAccountField(string $attribute_name) : string {
$value = '';
if (is_scalar($this->account
->get($attribute_name)->value)) {
$value = $this->account
->get($attribute_name)->value;
}
elseif (!empty($this->account
->get($attribute_name)
->getValue())) {
$file_reference = $this->account
->get($attribute_name)
->getValue();
if (isset($file_reference[0]['target_id'])) {
/** @var \Drupal\file\Entity\File $file */
$file = $this->entityTypeManager
->getStorage('file')
->load($file_reference[0]['target_id']);
if ($file) {
$value = file_get_contents($this->fileSystem
->realpath($file
->getFileUri()));
}
}
}
return $value;
}