public function CourseEventSubscriber::onRequest in Course 8.3
Same name and namespace in other branches
- 8.2 src/EventSubscriber/CourseEventSubscriber.php \Drupal\course\EventSubscriber\CourseEventSubscriber::onRequest()
- 3.x src/EventSubscriber/CourseEventSubscriber.php \Drupal\course\EventSubscriber\CourseEventSubscriber::onRequest()
Check if the current node will fulfill an object.
Parameters
GetResponseEvent $event:
File
- src/
EventSubscriber/ CourseEventSubscriber.php, line 26
Class
Namespace
Drupal\course\EventSubscriberCode
public function onRequest(GetResponseEvent $event) {
course_context();
if (!($course = course_get_context())) {
// Set course context for all modules that define course context handlers.
$handlers = course_get_handlers('object');
if (is_array($handlers)) {
foreach ($handlers as $handler) {
// We expect query parameters suitable for course_determine_context().
if ($params = call_user_func(array(
$handler['class'],
'context',
))) {
if (is_array($params) && isset($params['object_type']) && isset($params['instance'])) {
if ($course = course_determine_context($params['object_type'], $params['instance'])) {
// Set the course context.
course_set_context($course);
// Find and set the active object.
$course_object = course_get_course_object($params['object_type'], $params['instance'], $course);
$_SESSION['course'][$course
->id()]['taking']['active'] = $course_object
->id();
}
}
}
}
}
}
}