/** * Register a new user * * @param string $email * @param string $username * @param string $password * @return User */ public function registerUser($email, $username, $password) { $email = new Email($email); $username = new Username($username); $password = new Password($password); $this->checkEmailIsUnique($email); $this->checkUsernameIsUnique($username); $id = $this->userRepository->nextIdentity(); $password = $this->hashingService->hash($password); $user = User::register($id, $email, $username, $password); $this->userRepository->add($user); $this->dispatcher->dispatch($user->release()); return $user; }
/** * Register a new User * * @param RegisterUserCommand $command * @return Cribbb\Domain\Model\Identity\User */ public function registerUser(RegisterUserCommand $command) { $user = $this->registerUserService->register($command->email, $command->username, $command->password); $this->dispatcher->dispatch($user->release()); return $user; }