MAPG-193 replace Select usage to repository calls where it is easily possible

This commit is contained in:
bence committed 2020-07-05 15:17:28 +02:00
1 parent 45869321ac
commit 27fc687043
3 files changed
+26 -44

No files matched your search

+12 -1
View File
@@ -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);