コード例 #1
0
 public function testSetScheduled()
 {
     $interview = new Interview();
     $date = new \DateTime();
     $interview->setScheduled($date);
     $this->assertEquals($date, $interview->getScheduled());
 }
コード例 #2
0
 /**
  * Shows and handles the submission of the schedule interview form.
  * This method can also send an email to the applicant with the info from the submitted form.
  *
  * @param Request $request
  * @param Interview $interview
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function scheduleAction(Request $request, Interview $interview)
 {
     // Only admin and above, or the assigned interviewer should be able to book an interview
     if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN') && !$interview->isInterviewer($this->getUser())) {
         throw $this->createAccessDeniedException();
     }
     // Set the default data for the form
     $defaultData = array('datetime' => $interview->getScheduled(), 'message' => 'Hei, vi har satt opp et intervju for deg angående opptak til vektorprogrammet. ' . 'Dersom tidspunktet ikke passer, venligst send svar som retur til denne eposten.', 'from' => $interview->getInterviewer()->getEmail(), 'to' => $interview->getApplication()->getEmail());
     $form = $this->createForm(new ScheduleInterviewType(), $defaultData);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         // Update the scheduled time for the interview
         $interview->setScheduled($data['datetime']);
         $em = $this->getDoctrine()->getManager();
         $em->persist($interview);
         $em->flush();
         // Send email if the send button was clicked
         if ($form->get('saveAndSend')->isClicked()) {
             $mailer = $this->get('mailer');
             $message = $mailer->createMessage()->setSubject('Intervju for vektorprogrammet')->setFrom($data['from'])->setTo($data['to'])->setBody($this->renderView('interview/email.html.twig', array('message' => $data['message'], 'datetime' => $data['datetime'])), 'text/html');
             $mailer->send($message);
         }
         return $this->redirect($this->generateUrl('admissionadmin_show', array('status' => 'assigned')));
     }
     return $this->render('interview/schedule.html.twig', array('form' => $form->createView(), 'interview' => $interview));
 }