MAPG-193 replace Select usage to repository calls where it is easily possible
This commit is contained in:
3 files changed
+26
-44
No files matched your search
@@ -1,6 +1,8 @@
|
||||
<?php namespace MapGuesser\Repository;
|
||||
|
||||
use Generator;
|
||||
use MapGuesser\Database\Query\Select;
|
||||
use MapGuesser\PersistentData\Model\Map;
|
||||
use MapGuesser\PersistentData\Model\Place;
|
||||
use MapGuesser\PersistentData\PersistentDataManager;
|
||||
|
||||
@@ -18,6 +20,15 @@ class PlaceRepository
|
||||
return $this->pdm->selectFromDbById($placeId, Place::class);
|
||||
}
|
||||
|
||||
public function getAllForMap(Map $map): Generator
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('map_id', '=', $map->getId());
|
||||
|
||||
yield from $this->pdm->selectMultipleFromDb($select, Place::class);
|
||||
}
|
||||
|
||||
//TODO: use Map instead of id
|
||||
public function getRandomForMapWithValidPano(int $mapId, array $exclude = [], array &$placesWithoutPano): Place
|
||||
{
|
||||
$placesWithoutPano = [];
|
||||
@@ -37,7 +48,7 @@ class PlaceRepository
|
||||
|
||||
private function selectRandomFromDbForMap(int $mapId, array $exclude): ?Place
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection, 'places');
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('id', 'NOT IN', $exclude);
|
||||
$select->where('map_id', '=', $mapId);
|
||||
|
||||
|
||||
Reference in new issue
Block a user