-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreasonable_graph.module
More file actions
38 lines (35 loc) · 1.71 KB
/
reasonable_graph.module
File metadata and controls
38 lines (35 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* @file
* Primary module hooks for Reasonable Graph module.
*/
/**
* Implements hook_preprocess_HOOK() for page templates.
*/
function reasonable_graph_preprocess_page(array &$variables) {
/** @var User $account */
$account = \Drupal::currentUser();
$variables['user_roles'] = $account->getRoles();
$variables['username'] = $account->getDisplayName();
$variables['repo_admin'] = $account->hasPermission('acl_repo_admin');
$variables['repo_student'] = $account->hasPermission('acl_item_submitter_l1');
$variables['path'] = Drupal::service('path.current')->getPath();
$variables['lang'] = Drupal::languageManager()->getCurrentLanguage()->getId();
$variables['arc_laravel_host'] = \Drupal::config('reasonable_graph.settings')->get('arc_laravel_host');
}
function reasonable_graph_page_attachments(array &$attachments): void {
// Unconditionally attach an asset to the page.
//TODO: Load libraries only where needed - See src/RgJslLibraries - laravel routes
//Moved from rg base theme - global loading
$attachments['#attached']['library'][] = 'reasonable_graph/global-header';
$attachments['#attached']['library'][] = 'reasonable_graph/global-footer';
$attachments['#attached']['library'][] = 'reasonable_graph/select2';
$attachments['#attached']['library'][] = 'reasonable_graph/bootstrap-select';
$attachments['#attached']['library'][] = 'reasonable_graph/colorbox';
$attachments['#attached']['library'][] = 'reasonable_graph/jstree';
$attachments['#attached']['library'][] = 'reasonable_graph/flipster';
// Conditionally attach an asset to the page.
// if (!\Drupal::currentUser()->hasPermission('may pet kittens')) {
// $attachments['#attached']['library'][] = 'core/jquery';
// }
}