public function __construct(SessionEvent $sessionEvent)
 {
     $session = $sessionEvent->getSession();
     $course = $session->getCourse();
     $details = [];
     $details['id'] = $sessionEvent->getId();
     $details['name'] = $sessionEvent->getName();
     $details['startDate'] = $sessionEvent->getStartDate();
     $details['endDate'] = $sessionEvent->getEndDate();
     $details['sessionId'] = $session->getId();
     $details['sessionName'] = $session->getName();
     $details['courseId'] = $course->getId();
     $details['courseTitle'] = $course->getTitle();
     $details['courseCode'] = $course->getCode();
     foreach ($sessionEvent->getTutors() as $tutor) {
         $details['tutors'][] = ['id' => $tutor->getId(), 'username' => $tutor->getUsername(), 'firstName' => $tutor->getFirstName(), 'lastName' => $tutor->getLastName(), 'guid' => $tutor->getGuid()];
     }
     parent::__construct(self::ACTION, $details);
 }
 /**
  * @EXT\Route(
  *     "/courses/widget/session/event/{sessionEvent}/informations/mail/{withMail}",
  *     name="claro_courses_widget_session_event_informations",
  *     defaults={"withMail"=1},
  *     options={"expose"=true}
  * )
  * @EXT\Template("ClarolineCursusBundle:Cursus:sessionEventInformationsModal.html.twig")
  */
 public function coursesWidgetSessionEventInformationsAction(SessionEvent $sessionEvent, $withMail = 1)
 {
     return ['event' => $sessionEvent, 'session' => $sessionEvent->getSession(), 'course' => $sessionEvent->getSession()->getCourse(), 'location' => $sessionEvent->getLocation(), 'locationExtra' => $sessionEvent->getLocationExtra(), 'tutors' => $sessionEvent->getTutors(), 'withMail' => intval($withMail) === 1];
 }
Example #3
0
 public function convertKeysForSessionEvent(SessionEvent $event, $content, User $user = null)
 {
     $session = $event->getSession();
     $course = $session->getCourse();
     $location = $event->getLocation();
     $eventTrainers = $event->getTutors();
     $sessionTrainers = $this->getUsersBySessionAndType($session, CourseSessionUser::TEACHER);
     $sessionTrainersHtml = '';
     $locationHtml = '';
     $eventTrainersHtml = '';
     if (!is_null($location)) {
         $locationHtml = $location->getStreet() . ', ' . $location->getStreetNumber();
         $locationHtml .= $location->getBoxNumber() ? ' / ' . $location->getBoxNumber() : '';
         $locationHtml .= '<br>' . $location->getPc() . ' ' . $location->getTown() . '<br>' . $location->getCountry();
         $locationHtml .= $location->getPhone() ? '<br>' . $location->getPhone() : '';
     }
     if (count($sessionTrainers) > 0) {
         $sessionTrainersHtml = '<ul>';
         foreach ($sessionTrainers as $trainer) {
             $sessionTrainersHtml .= '<li>' . $trainer->getFirstName() . ' ' . $trainer->getLastName() . '</li>';
         }
         $sessionTrainersHtml .= '</ul>';
     }
     if (count($eventTrainers) > 0) {
         $eventTrainersHtml = '<ul>';
         foreach ($eventTrainers as $trainer) {
             $eventTrainersHtml .= '<li>' . $trainer->getFirstName() . ' ' . $trainer->getLastName() . '</li>';
         }
         $eventTrainersHtml .= '</ul>';
     }
     $now = new \DateTime();
     $keys = ['%date%', '%course_title%', '%course_code%', '%course_description%', '%session_name%', '%session_description%', '%session_start%', '%session_end%', '%session_trainers%', '%event_name%', '%event_description%', '%event_start%', '%event_end%', '%event_location%', '%event_location_extra%', '%event_trainers%'];
     $values = [$now->format('d/m/Y'), $course->getTitle(), $course->getCode(), $course->getDescription(), $session->getName(), $session->getDescription(), $session->getStartDate()->format('d/m/Y'), $session->getEndDate()->format('d/m/Y'), $sessionTrainersHtml, $event->getName(), $event->getDescription(), $event->getStartDate()->format('d/m/Y H:i'), $event->getEndDate()->format('d/m/Y H:i'), $locationHtml, $event->getLocationExtra(), $eventTrainersHtml];
     if (!is_null($user)) {
         $keys[] = '%first_name%';
         $keys[] = '%last_name%';
         $values[] = $user->getFirstName();
         $values[] = $user->getLastName();
     }
     return str_replace($keys, $values, $content);
 }