/** * @param AddWishRequest $request * * @return mixed|void * * @throws UserDoesNotExistException */ public function execute($request = null) { $userId = $request->userId(); $address = $request->email(); $content = $request->content(); $user = $this->userRepository->ofId(new UserId($userId)); if (null === $user) { throw new UserDoesNotExistException(); } $this->wishRepository->add($user->makeWishNotBeingAnAggregate($this->wishRepository->nextIdentity(), $address, $content)); }
/** * @param AddWishRequest $request * @return mixed|void * @throws UserDoesNotExistException */ public function execute($request = null) { $userId = $request->userId(); $email = $request->email(); $content = $request->content(); $user = $this->userRepository->userOfId(new UserId($userId)); if (null === $user) { throw new UserDoesNotExistException(); } $this->wishRepository->persist($user->makeWish($this->wishRepository->nextIdentity(), $email, $content)); }