Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
CRAP | n/a |
0 / 0 |
|
authorization_help | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
authorization_user_login | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | /** |
4 | * @file |
5 | * Contains authorization.module. |
6 | */ |
7 | |
8 | declare(strict_types=1); |
9 | |
10 | use Drupal\Core\Routing\RouteMatchInterface; |
11 | |
12 | /** |
13 | * Implements hook_help(). |
14 | */ |
15 | function authorization_help($route_name, RouteMatchInterface $route_match) { |
16 | if ($route_name === 'help.page.authorization') { |
17 | $output = ''; |
18 | $output .= '<h3>' . t('About') . '</h3>'; |
19 | $output .= '<p>' . t('Authorization API connects up providers (for example LDAP) with consumers (for example Organic Groups or Drupal roles).') . '</p>'; |
20 | return $output; |
21 | } |
22 | } |
23 | |
24 | /** |
25 | * Implements hook_user_login(). |
26 | */ |
27 | function authorization_user_login($account) { |
28 | /** @var \Drupal\authorization\AuthorizationServiceInterface $service */ |
29 | $service = \Drupal::service('authorization.manager'); |
30 | $service->setUser($account); |
31 | $service->setAllProfiles(); |
32 | $processed_authorizations = $service->getProcessedAuthorizations(); |
33 | |
34 | if (\Drupal::config('authorization.settings')->get('authorization_message')) { |
35 | foreach ($processed_authorizations as $authorization) { |
36 | \Drupal::messenger()->addStatus(t('Done with @authorization', ['@authorization' => $authorization->getMessage()]), TRUE); |
37 | } |
38 | } |
39 | } |