adapt Container usage to new soko-web
This commit is contained in:
23 files changed
+248
-397
No files matched your search
@@ -5,23 +5,15 @@ use SokoWeb\Database\Query\Select;
|
||||
use MapGuesser\PersistentData\Model\User;
|
||||
use MapGuesser\PersistentData\Model\Place;
|
||||
use MapGuesser\PersistentData\Model\UserPlayedPlace;
|
||||
use SokoWeb\PersistentData\PersistentDataManager;
|
||||
|
||||
class UserPlayedPlaceRepository
|
||||
{
|
||||
private PersistentDataManager $pdm;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pdm = new PersistentDataManager();
|
||||
}
|
||||
|
||||
public function getByUser(User $user): Generator
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('user_id', '=', $user->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, UserPlayedPlace::class);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, UserPlayedPlace::class);
|
||||
}
|
||||
|
||||
public function getAllByPlace(Place $place): Generator
|
||||
@@ -29,7 +21,7 @@ class UserPlayedPlaceRepository
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('place_id', '=', $place->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, UserPlayedPlace::class);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, UserPlayedPlace::class);
|
||||
}
|
||||
|
||||
public function getAllByUser(User $user) : Generator
|
||||
@@ -37,7 +29,7 @@ class UserPlayedPlaceRepository
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('user_id', '=', $user->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, UserPlayedPlace::class);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, UserPlayedPlace::class);
|
||||
}
|
||||
|
||||
public function getByUserIdAndPlaceId(int $userId, int $placeId) : ?UserPlayedPlace
|
||||
@@ -46,6 +38,6 @@ class UserPlayedPlaceRepository
|
||||
$select->where('user_id', '=', $userId);
|
||||
$select->where('place_id', '=', $placeId);
|
||||
|
||||
return $this->pdm->selectFromDb($select, UserPlayedPlace::class);
|
||||
return \Container::$persistentDataManager->selectFromDb($select, UserPlayedPlace::class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user