/** * This function get the form. * * @Post * @Logged * @URL /get-form */ public function submit_form($nom = null, $prenom = null, $fonction = null, $institution = null, $telephone = null, $email = null, $adresse = null, $ville = null, $radio = null) { if (!empty($nom) && !empty($prenom) && !empty($fonction) && !empty($institution) && !empty($telephone) && !empty($email) && !empty($adresse) && !empty($ville) && !empty($radio)) { // Getting the current user object from the user service. $user = $this->userService->getLoggedUser(); // Getting cotisation object with his id from the radio. $cotisation = $this->cotisationDao->getById($radio); // Create an object of client. $client = $this->clientDao->create(); // Setting all the value into the DB. $client->setNom($nom); $client->setPrenom($prenom); $client->setFonction($fonction); $client->setInstitution($institution); $client->setTelephone($telephone); $client->setEmail($email); $client->setAdresse($adresse); $client->setVille($ville); $client->setUser($user); $client->setCotisation($cotisation); $client->setDeleted(self::NEW_USER); $client->setCreatedAt(new \DateTime()); // Save all the data. $this->clientDao->save($client); $this->entityManager->flush(); set_user_message('Le client a été ajouté.', UserMessageInterface::SUCCESS); header('Location: ' . ROOT_URL); } else { set_user_message('Le formulaire n\'est pas valide.'); header('Location: ' . ROOT_URL . 'add_client'); } }
/** * @return \Mouf\Security\UserService\UserInterface|null */ public function getUser() { return $this->userService->getLoggedUser(); }