public function addAction(Request $request, Application $app)
 {
     $newStudent = new Student();
     $class = $app['dao.className']->findClassname($request->request->get('classname'));
     $statuts = $app['dao.statutStudent']->findStatut($request->request->get('statut'));
     if (null !== $request->request->get('id_student')) {
         $newStudent->setIdStudent($request->request->get('id_student'));
     }
     $newStudent->setName($request->request->get('name'));
     $newStudent->setFirstname($request->request->get('firstname'));
     $newStudent->setBirthday($request->request->get('birthday'));
     $newStudent->setAddress($request->request->get('address'));
     $newStudent->setTel($request->request->get('phone'));
     $newStudent->setEmail($request->request->get('email'));
     $newStudent->setDtCreate(date('Y-m-d H:i:s'));
     $newStudent->setDtUpdate(date('Y-m-d H:i:s'));
     $newStudent->setClass($class);
     $newStudent->setStatut($statuts);
     $app['dao.student']->saveStudent($newStudent);
     $classes = $app['dao.className']->findAll();
     if (null !== $request->request->get('id_student')) {
         $app['session']->getFlashBag()->add('success', 'L\'étudiant a bien été modifiée !');
         //message flash success si réussi
         return $app->redirect($app['url_generator']->generate('studentslist'));
     } else {
         $app['session']->getFlashBag()->add('success', 'L\'étudiant a bien été ajouté !');
         //message flash success si réussi
         return $app->redirect($app['url_generator']->generate('studentslist'));
     }
 }
Exemple #2
0
 /**
  * @param $row
  * @return Student
  *
  * Construction d'un objet étudiant
  */
 protected function buildDomainObject($row)
 {
     $student = new Student();
     $student->setIdStudent($row['id_student']);
     $student->setName($row['student_name']);
     $student->setFirstname($row['student_firstname']);
     $student->setBirthday($row['student_birthday']);
     $student->setAddress($row['student_address']);
     $student->setEmail($row['student_email']);
     $student->setTel($row['student_tel']);
     $student->setDtCreate($row['dt_create']);
     $student->setDtUpdate($row['dt_update']);
     $classNameID = $row['id_class'];
     if ($classNameID) {
         $classname = $this->classDAO->findClassname($classNameID);
         $student->setClass($classname);
     }
     if (array_key_exists('id_statut', $row)) {
         $statutID = $row['id_statut'];
         $statut = $this->statutDAO->findStatut($statutID);
         $student->setStatut($statut);
     }
     return $student;
 }