/** * @Route("/schedule/course/{id}", name="schedule_course") * @Template() */ public function courseAction(Course $course) { if (!$this->getUserLayer()->isStudent()) { return $this->createAccessDeniedResponse(); } /** @var $em EntityManager */ $em = $this->getDoctrine()->getManager(); $students = $em->createQueryBuilder()->select('c, u')->from('EtuUserBundle:Course', 'c')->leftJoin('c.user', 'u')->where('c.uv = :uv')->andWhere('c.start = :start')->andWhere('c.end = :end')->andWhere('c.week = :week')->andWhere('c.room = :room')->setParameter('uv', $course->getUv())->setParameter('start', $course->getStart())->setParameter('end', $course->getEnd())->setParameter('week', $course->getWeek())->setParameter('room', $course->getRoom())->orderBy('u.lastName', 'ASC')->getQuery()->getResult(); return array('course' => $course, 'students' => $students); }
/** * @param Course $course * @return array */ private function getData(Course $course) { $start = explode(':', $course->getStart()); $end = explode(':', $course->getEnd()); return ['day' => $course->getDay(), 'start' => ['hour' => (int) $start[0], 'minute' => (int) $start[1]], 'end' => ['hour' => (int) $end[0], 'minute' => (int) $end[1]], 'week' => $course->getWeek(), 'uv' => $course->getUv(), 'type' => $course->getType(), 'room' => $course->getRoom()]; }