public function createUser($params) { $checkEmail = $this->checkEmail($params['email']); if ($checkEmail) { throw new \Exception("Adresa email deja folosita", 1); } $user = new Entities\User(); $user->postHydrate($params); $roleRep = $this->em->getRepository("Entities:AclRole")->findBy(array("name" => $params['role'])); if (!isset($roleRep[0])) { throw new \Exception("Invalid Role", 1); } $user->setAclRole($roleRep[0]); if (!$params['password']) { $params['password'] = $this->randString(10); } $user->setPassword(sha1($params['password'])); try { $this->em->persist($user); $this->em->flush(); } catch (\Exception $e) { echo $e->getMessage(); exit; return false; } $this->sendNotification($user); // $this->subscribeUser($user); return $user; }