You are here

function ldap_user_user_presave in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.2 ldap_user/ldap_user.module \ldap_user_user_presave()
  2. 7.2 ldap_user/ldap_user.module \ldap_user_user_presave()

Implements hook_ENTITY_TYPE_presave().

File

ldap_user/ldap_user.module, line 117

Code

function ldap_user_user_presave($account) {

  /** @var \Drupal\ldap_user\Processor\DrupalUserProcessor $processor */
  $processor = \Drupal::service('ldap.drupal_user_processor');
  if (!$account
    ->isNew()) {

    // We apply any data from LDAP to the Drupal user (if configured to do so)
    // before saving the user to avoid multiple saves on the entity.
    // We only do this after initial creation since we are otherwise potentially
    // querying for users that are set to be excluded on creation.
    $processor
      ->drupalUserUpdate($account);
  }
}