Answer the question
In order to leave comments, you need to log in
Pass object or simple data to CQRS command?
/**
* @throws JsonException
*/
public function resetPassword(
UserResetPasswordToken $resetPasswordToken,
ResetPasswordRequest $request
): JsonResponse {
$token = $resetPasswordToken->token();
$this->commandBus->dispatch(
(new UpdateUser((new UserFilter())->setResetPasswordToken($token), $request->ip()))
class UpdateUser {
public UserFilter $filter;
public string $ip;
public function __construct(
UserFilter $filter,
string $ip
) {
$this->filter = $filter;
$this->ip = $ip;
...
private function update(UpdateUser $command): void {
$entity = $this->userRepository->single($command->filter);
/**
* @throws JsonException
*/
public function resetPassword(
ResetPasswordRequest $request
): JsonResponse {
$this->commandBus->dispatch(
(new UpdateUser(UserFilter::fromRequest($request), $request->ip()))
/**
* @throws JsonException
*/
public function resetPassword(
UserResetPasswordToken $resetPasswordToken,
ResetPasswordRequest $request
): JsonResponse {
$token = $resetPasswordToken->token();
/** @var User $user */
$user = $this->handle(new GetSingleUser((new UserFilter())->setResetPasswordToken($token)));
$this->commandBus->dispatch(
(new UpdateUser($user->id->value(), $request->ip()))
->setResetPasswordToken($token)
class UpdateUser {
public string $ip;
public string $id;
public function __construct(
string $id,
string $ip
) {
$this->id = $id;
$this->ip = $ip;
private function update(UpdateUser $command): void {
$filter = (new UserFilter())->setUuid($command->id);
$entity = $this->userRepository->single($filter);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question