repo->ofEmail($cmd->email); // Check if user is active. If not, throw a UserNotFoundException. if ($user->getStatus() !== Status::ACTIVE) { throw new UserNotFoundException($cmd->email); } // Generate a recovery token for the user $user->generateRecoveryToken(); // Create and dispatch a new PasswordRecoveryCreatedEvent with the // updated user $event = new PasswordRecoveryCreatedEvent($user); $this->dispatcher->dispatch($event); } }