function opigno_learning_path_is_lp_route in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 opigno_learning_path.module \opigno_learning_path_is_lp_route()
Returns LP route flag.
6 calls to opigno_learning_path_is_lp_route()
- opigno_learning_path_preprocess_html in ./
opigno_learning_path.module - Implements hook_preprocess_html().
- opigno_learning_path_preprocess_page in ./
opigno_learning_path.module - Implements hook_preprocess_page().
- opigno_learning_path_preprocess_region in ./
opigno_learning_path.module - Implements hook_preprocess_region().
- opigno_learning_path_preprocess_status_messages in ./
opigno_learning_path.module - Implements hook_preprocess_HOOK().
- opigno_learning_path_theme_suggestions_alter in ./
opigno_learning_path.module - Implements hook_theme_suggestions_alter().
File
- ./
opigno_learning_path.module, line 1038 - Contains opigno_learning_path.module.
Code
function opigno_learning_path_is_lp_route() {
$route = \Drupal::routeMatch()
->getRouteName();
$is_learning_path = FALSE;
$routes = [
'opigno_group_manager.manager.index',
'opigno_learning_path.learning_path_modules',
'opigno_learning_path.learning_path_courses',
'opigno_learning_path.membership.overview',
'entity.group_content.add_form',
'opigno_module.add',
'opigno_module.edit',
'opigno_module.modules',
'opigno_module.activities_bank',
];
if ($route == 'entity.group.add_form' && (\Drupal::routeMatch()
->getParameter('group_type')
->id() == 'opigno_course' || \Drupal::routeMatch()
->getParameter('group_type')
->id() == 'learning_path' || \Drupal::routeMatch()
->getParameter('group_type')
->id() == 'opigno_class')) {
$is_learning_path = TRUE;
}
if ($route == 'entity.group.edit_form' && (\Drupal::routeMatch()
->getParameter('group')
->get('type')
->getString() == 'opigno_course' || \Drupal::routeMatch()
->getParameter('group')
->get('type')
->getString() == 'learning_path' || \Drupal::routeMatch()
->getParameter('group')
->get('type')
->getString() == 'opigno_class')) {
$is_learning_path = TRUE;
}
if (in_array($route, $routes)) {
$is_learning_path = TRUE;
}
return $is_learning_path;
}