MAPG-140 refactor user handling to use the PersistentDataManager

This commit is contained in:
bence committed 2020-06-20 02:03:11 +02:00
1 parent d6750777c2
commit a9eec05288
6 files changed
+78 -60

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
<?php namespace MapGuesser\Repository;
use MapGuesser\Database\Query\Select;
use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\PersistentDataManager;
class UserRepository
{
private PersistentDataManager $pdm;
public function __construct()
{
$this->pdm = new PersistentDataManager();
}
public function getById(int $userId): ?User
{
return $this->pdm->selectFromDbById($userId, User::class);
}
public function getByEmail(string $email): ?User
{
$select = new Select(\Container::$dbConnection);
$select->where('email', '=', $email);
return $this->pdm->selectFromDb($select, User::class);
}
}