You are here

authorization.module in Authorization 8

File

authorization.module
View source
<?php

declare (strict_types=1);

/**
 * @file
 * Contains authorization.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function authorization_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.authorization') {
    $output = '';
    $output .= '<h3>' . t('About') . '</h3>';
    $output .= '<p>' . t('Authorization API connects up providers (for example LDAP) with consumers (for example Organic Groups or Drupal roles).') . '</p>';
    return $output;
  }
}

/**
 * Implements hook_user_login().
 */
function authorization_user_login($account) {

  /** @var \Drupal\authorization\AuthorizationController $controller */
  $controller = \Drupal::service('authorization.manager');
  $controller
    ->setUser($account);
  $controller
    ->setAllProfiles();
  $processed_authorizations = $controller
    ->getProcessedAuthorizations();
  if (\Drupal::config('authorization.settings')
    ->get('authorization_message')) {
    foreach ($processed_authorizations as $authorization) {
      \Drupal::messenger()
        ->addStatus(t('Done with @authorization', [
        '@authorization' => $authorization
          ->getMessage(),
      ]), TRUE);
    }
  }
}

Functions