function opigno_module_preprocess_page in Opigno module 8
Same name and namespace in other branches
- 3.x opigno_module.module \opigno_module_preprocess_page()
Implements hook_preprocess_page().
File
- ./
opigno_module.module, line 785 - Contains opigno_module.module.
Code
function opigno_module_preprocess_page(&$variables) {
if (opigno_module_is_activity_route()) {
$user = \Drupal::currentUser();
if ($gid = OpignoGroupContext::getCurrentGroupId()) {
if ($group = \Drupal::entityTypeManager()
->getStorage('group')
->load($gid)) {
$home_link = Link::createFromRoute(t('home'), 'entity.group.canonical', [
'group' => $group
->id(),
], [
'attributes' => [
'class' => [
'w-100',
],
],
])
->toRenderable();
$variables['home_link'] = render($home_link);
}
}
if ($user && isset($group)) {
$progress_service = \Drupal::service('opigno_learning_path.progress');
$variables['progress'] = $progress_service
->getProgressRound($group
->id(), $user
->id());
}
$variables['attributes']['class'][] = 'section-module';
}
$route_name = \Drupal::routeMatch()
->getRouteName();
if (!empty($_SESSION['activities_bank']) && $route_name != 'opigno_module.activities_bank_lpm') {
unset($_SESSION['activities_bank']);
}
}