adapt Container usage to new soko-web
This commit is contained in:
23 files changed
+248
-397
No files matched your search
@@ -5,20 +5,12 @@ use SokoWeb\Database\Query\Select;
|
||||
use MapGuesser\PersistentData\Model\Challenge;
|
||||
use MapGuesser\PersistentData\Model\Map;
|
||||
use MapGuesser\PersistentData\Model\Place;
|
||||
use SokoWeb\PersistentData\PersistentDataManager;
|
||||
|
||||
class PlaceRepository
|
||||
{
|
||||
private PersistentDataManager $pdm;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pdm = new PersistentDataManager();
|
||||
}
|
||||
|
||||
public function getById(int $placeId): ?Place
|
||||
{
|
||||
return $this->pdm->selectFromDbById($placeId, Place::class);
|
||||
return \Container::$persistentDataManager->selectFromDbById($placeId, Place::class);
|
||||
}
|
||||
|
||||
public function getAllForMap(Map $map): Generator
|
||||
@@ -26,7 +18,7 @@ class PlaceRepository
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('map_id', '=', $map->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, Place::class);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Place::class);
|
||||
}
|
||||
|
||||
//TODO: use Map and User instead of id
|
||||
@@ -99,7 +91,7 @@ class PlaceRepository
|
||||
$select->where('id', 'NOT IN', $exclude);
|
||||
$select->limit(1, $randomOffset);
|
||||
|
||||
return $this->pdm->selectFromDb($select, Place::class);
|
||||
return \Container::$persistentDataManager->selectFromDb($select, Place::class);
|
||||
}
|
||||
|
||||
// Never visited places
|
||||
@@ -186,7 +178,7 @@ class PlaceRepository
|
||||
$select->orderBy('round');
|
||||
$select->limit(1, $round);
|
||||
|
||||
return $this->pdm->selectFromDb($select, Place::class);
|
||||
return \Container::$persistentDataManager->selectFromDb($select, Place::class);
|
||||
}
|
||||
|
||||
public function getAllInChallenge(Challenge $challenge): Generator
|
||||
@@ -196,7 +188,7 @@ class PlaceRepository
|
||||
$select->where('challenge_id', '=', $challenge->getId());
|
||||
$select->orderBy('round');
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, Place::class);
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Place::class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user