public function postUserAction(\Symfony\Component\HttpFoundation\Request $request) { $em = $this->getDoctrine()->getEntityManager(); $return = "false"; $user = new User(); $json = json_decode($this->getRequest($request)->getContent(), true); $user->setUsername($json['username']); $user->setPassword($json['password']); $query = $em->createQuery('SELECT u FROM iiaApiBundle:User u WHERE u.username = :username AND u.password = :password'); $query->setParameter(":username", $json['username']); $query->setParameter(":password", $json['password']); $return = $query->getResult(); // return $this->handleView($view); return $return; }
public function load(ObjectManager $em) { $userAdmin = new User(); $userAdmin->setEmail("*****@*****.**"); $userAdmin->setSuperAdmin(true); $userAdmin->setUsername("admin"); $userAdmin->setPlainPassword("password"); $userAdmin->setEnabled(true); $em->persist($userAdmin); for ($i = 0; $i < 20; $i++) { $user = new User(); $user->setEmail("user" . $i . "@test.fr"); $isadmin = false; if ($i < 3) { $isadmin = true; } $user->setSuperAdmin($isadmin); $user->setUsername("user" . $i); $user->setPlainPassword("password"); $user->setEnabled(true); $em->persist($user); $this->addReference('user' . $i, $user); $group = new \IIA\ApiBundle\Entity\UserGroup(); if ($i < 5) { $group = $this->getReference("group-BTS1"); } elseif ($i < 10) { $group = $this->getReference("group-CDSM"); } elseif ($i < 15) { $group = $this->getReference("group-BTS2"); } else { $group = $this->getReference("group-M2"); } $user->addUserGroup($group); } $em->flush(); $this->addReference('userAdmin', $userAdmin); }
/** * Remove user Registration * * @param \IIA\ApiBundle\Entity\User $user */ public function removeUserRegistration(\IIA\ApiBundle\Entity\User $user) { $user->removeSessionRegistration($this); $this->usersRegistred->removeElement($user); }
/** * Remove user From Group * * @param \IIA\ApiBundle\Entity\User $user */ public function removeUserFromGroup(\IIA\ApiBundle\Entity\User $user) { $user->removeUserGroup($this); $this->users->removeElement($user); }