diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 83f3c89..18b4dee 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -184,7 +184,8 @@ class UserController implements ISecured \Container::$dbConnection->startTransaction(); - foreach ($this->userConfirmationRepository->getByUser($user) as $userConfirmation) { + $userConfirmation = $this->userConfirmationRepository->getByUser($user); + if ($userConfirmation !== null) { $this->pdm->deleteFromDb($userConfirmation); } diff --git a/src/Repository/UserConfirmationRepository.php b/src/Repository/UserConfirmationRepository.php index 5c0723e..d7d80ad 100644 --- a/src/Repository/UserConfirmationRepository.php +++ b/src/Repository/UserConfirmationRepository.php @@ -1,8 +1,6 @@ pdm->selectFromDb($select, UserConfirmation::class); } - public function getByUser(User $user): Generator + public function getByUser(User $user): ?UserConfirmation { $select = new Select(\Container::$dbConnection); $select->where('user_id', '=', $user->getId()); - yield from $this->pdm->selectMultipleFromDb($select, UserConfirmation::class); + return $this->pdm->selectFromDb($select, UserConfirmation::class); } }