private function initPlayers() { $playerId = 0; $player = new Player(); $playerId++; $player->setId($playerId); $player->setUsername('BlackScorp'); $player->setPassword($this->hasher->hash('123456')); $player->setEmail('*****@*****.**'); $roles = new PlayerRoles(); $roles->addRole($this->roleRepository->findByName('Player')); $player->setRoles($roles); $this->playerRepository->save($player); }
public function __invoke(Request $request) { $player = $this->_playerRepository->findByUsername($request->getUsername()); if (!$player) { throw new NotExistsException(); } if (!(bool) $player->getActivationCode()) { throw new AlreadyActiveException(); } if ($player->getActivationCode() !== $request->getCode()) { throw new InvalidCodeException(); } $player->setActivationCode(''); $roles = new PlayerRoles(); $roles->addRole($request->getRole()); $player->setRoles($roles); $this->_playerRepository->save($player); return new Response($player); }
public function setRoles(Roles $roles) { $roles->setPlayer($this); $this->_roles = $roles; return $this; }