|
|
@ -49,6 +49,7 @@ class CourseListener |
|
|
|
if ($request->attributes->get('_route') === '_wdt') { |
|
|
|
if ($request->attributes->get('_route') === '_wdt') { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Ignore toolbar |
|
|
|
// Ignore toolbar |
|
|
|
if ($request->attributes->get('_profiler') === '_wdt') { |
|
|
|
if ($request->attributes->get('_profiler') === '_wdt') { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -58,12 +59,11 @@ class CourseListener |
|
|
|
|
|
|
|
|
|
|
|
$container = $this->container; |
|
|
|
$container = $this->container; |
|
|
|
$translator = $container->get('translator'); |
|
|
|
$translator = $container->get('translator'); |
|
|
|
$course = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if URL has cid value |
|
|
|
|
|
|
|
if ($request->attributes->has('cid')) { |
|
|
|
|
|
|
|
$courseId = $request->get('cid'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$course = null; |
|
|
|
|
|
|
|
// Check if URL has cid value. Using Symfony request. |
|
|
|
|
|
|
|
$courseId = $request->get('cid'); |
|
|
|
|
|
|
|
if (!empty($courseId)) { |
|
|
|
/** @var EntityManager $em */ |
|
|
|
/** @var EntityManager $em */ |
|
|
|
$em = $container->get('doctrine')->getManager(); |
|
|
|
$em = $container->get('doctrine')->getManager(); |
|
|
|
$checker = $container->get('security.authorization_checker'); |
|
|
|
$checker = $container->get('security.authorization_checker'); |
|
|
@ -82,16 +82,19 @@ class CourseListener |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (null !== $course) { |
|
|
|
if (null !== $course) { |
|
|
|
$sessionHandler->set('courseObj', $course); |
|
|
|
// Setting variables in the session. |
|
|
|
$courseInfo = api_get_course_info($course->getCode()); |
|
|
|
$sessionHandler->set('course', $course); |
|
|
|
$container->get('twig')->addGlobal('course', $course); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sessionHandler->set('_real_cid', $course->getId()); |
|
|
|
$sessionHandler->set('_real_cid', $course->getId()); |
|
|
|
$sessionHandler->set('cid', $course->getId()); |
|
|
|
$sessionHandler->set('cid', $course->getId()); |
|
|
|
$sessionHandler->set('_cid', $course->getCode()); |
|
|
|
$sessionHandler->set('_cid', $course->getCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$courseInfo = api_get_course_info($course->getCode()); |
|
|
|
$sessionHandler->set('_course', $courseInfo); |
|
|
|
$sessionHandler->set('_course', $courseInfo); |
|
|
|
|
|
|
|
|
|
|
|
// Session |
|
|
|
// Setting variables for the twig templates. |
|
|
|
|
|
|
|
$container->get('twig')->addGlobal('course', $course); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Checking if sid is used. |
|
|
|
$sessionId = (int) $request->get('sid'); |
|
|
|
$sessionId = (int) $request->get('sid'); |
|
|
|
$session = null; |
|
|
|
$session = null; |
|
|
|
if (empty($sessionId)) { |
|
|
|
if (empty($sessionId)) { |
|
|
@ -120,9 +123,9 @@ class CourseListener |
|
|
|
|
|
|
|
|
|
|
|
$sessionHandler->set('session_name', $session->getName()); |
|
|
|
$sessionHandler->set('session_name', $session->getName()); |
|
|
|
$sessionHandler->set('sid', $session->getId()); |
|
|
|
$sessionHandler->set('sid', $session->getId()); |
|
|
|
$sessionHandler->set('sessionObj', $session); |
|
|
|
$sessionHandler->set('session', $session); |
|
|
|
|
|
|
|
|
|
|
|
$container->get('twig')->addGlobal('sessionObj', $session); |
|
|
|
$container->get('twig')->addGlobal('session', $session); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new NotFoundHttpException($translator->trans('Session not found')); |
|
|
|
throw new NotFoundHttpException($translator->trans('Session not found')); |
|
|
|
} |
|
|
|
} |
|
|
|