You are here

private function GroupUserUpdateProcessor::updateAuthorizations in Lightweight Directory Access Protocol (LDAP) 8.3

Same name and namespace in other branches
  1. 8.4 ldap_user/src/Processor/GroupUserUpdateProcessor.php \Drupal\ldap_user\Processor\GroupUserUpdateProcessor::updateAuthorizations()

Update authorizations.

Parameters

\Drupal\user\Entity\User $user: Drupal user to update.

1 call to GroupUserUpdateProcessor::updateAuthorizations()
GroupUserUpdateProcessor::runQuery in ldap_user/src/Processor/GroupUserUpdateProcessor.php
Runs the updating mechanism.

File

ldap_user/src/Processor/GroupUserUpdateProcessor.php, line 98

Class

GroupUserUpdateProcessor
Provides functionality to generically update existing users.

Namespace

Drupal\ldap_user\Processor

Code

private function updateAuthorizations(User $user) {
  if ($this->moduleHandler
    ->moduleExists('ldap_authorization')) {

    // We are not injecting this service properly to avoid forcing this
    // dependency on authorization.

    /** @var \Drupal\authorization\AuthorizationController $authorization_manager */
    $authorization_manager = \Drupal::service('authorization.manager');
    $authorization_manager
      ->setUser($user);
    $authorization_manager
      ->setAllProfiles();
  }
  else {

    // We are saving here for sites without ldap_authorization since saving is
    // embedded in setAllProfiles().
    // TODO: Provide method for decoupling saving users and use it instead.
    $user
      ->save();
  }
}