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\Challenge;
|
||||
use MapGuesser\PersistentData\Model\Place;
|
||||
use MapGuesser\PersistentData\Model\PlaceInChallenge;
|
||||
use SokoWeb\PersistentData\PersistentDataManager;
|
||||
|
||||
class PlaceInChallengeRepository
|
||||
{
|
||||
private PersistentDataManager $pdm;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pdm = new PersistentDataManager();
|
||||
}
|
||||
|
||||
public function getAllByPlace(Place $place, array $withRelations = []) : Generator
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('place_id', '=', $place->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, PlaceInChallenge::class, true, $withRelations);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, PlaceInChallenge::class, true, $withRelations);
|
||||
}
|
||||
|
||||
public function getAllByChallenge(Challenge $challenge) : Generator
|
||||
@@ -29,7 +21,7 @@ class PlaceInChallengeRepository
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('challenge_id', '=', $challenge->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, PlaceInChallenge::class);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, PlaceInChallenge::class);
|
||||
}
|
||||
|
||||
public function getByPlaceAndChallenge(Place $place, Challenge $challenge) : ?PlaceInChallenge
|
||||
@@ -38,7 +30,7 @@ class PlaceInChallengeRepository
|
||||
$select->where('place_id', '=', $place->getId());
|
||||
$select->where('challenge_id', '=', $challenge->getId());
|
||||
|
||||
return $this->pdm->selectFromDb($select, PlaceInChallenge::class);
|
||||
return \Container::$persistentDataManager->selectFromDb($select, PlaceInChallenge::class);
|
||||
}
|
||||
|
||||
public function getByRoundInChallenge(int $round, Challenge $challenge, array $withRelations = []): ?PlaceInChallenge
|
||||
@@ -48,6 +40,6 @@ class PlaceInChallengeRepository
|
||||
$select->orderBy('round');
|
||||
$select->limit(1, $round);
|
||||
|
||||
return $this->pdm->selectFromDb($select, PlaceInChallenge::class, true, $withRelations);
|
||||
return \Container::$persistentDataManager->selectFromDb($select, PlaceInChallenge::class, true, $withRelations);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user