/** * @param Request $request * @param Response $response */ public function signupUser(Request $request, Response $response) { $username = $request->getParam('username'); $password = $request->getParam('password'); $email = $request->getParam('email'); $u = $this->em->getRepository('App\\Model\\User')->findOneBy(array('username' => $username)); if ($u != []) { echo "Username nay da ton tai"; } else { $user = new User(); $user->setUsername($username); $user->setPassword($password); $user->setEmail($email); $this->em->persist($user); $this->em->flush(); echo "Da them thanh vien moi thanh cong"; } }
private function setValueFromRequest(User $user, Request $request) { if (!empty($request->get('email'))) { $user->setEmail($request->get('email')); } if (!empty($request->get('password'))) { $user->setPassword($this->hasher->hashPassword($request->get('password'))); } if (!empty($request->get('role'))) { $user->setRole($request->get('role')); } }
private function insertUser(Request $request) { $email = $request->get('email'); $password = $request->get('password'); $user = new User(); $user->setEmail($email); $user->setPassword($this->hasher->hashPassword($password)); $this->em->persist($user); $this->em->flush(); }