feature/update-soko-web-to-0.7 #62

Merged
bence merged 2 commits from feature/update-soko-web-to-0.7 into develop 2023-04-30 21:07:08 +02:00
4 changed files with 10 additions and 10 deletions
Showing only changes of commit e70f8a9965 - Show all commits

View File

@ -138,7 +138,7 @@ class GameFlowController implements IAuthenticationRequired
// if the last round was played ($currentPlace == null) or history is explicitly requested (for initializing) // if the last round was played ($currentPlace == null) or history is explicitly requested (for initializing)
if (!isset($currentPlace) || $withHistory) { if (!isset($currentPlace) || $withHistory) {
$withRelations = [User::class, PlaceInChallenge::class, Place::class]; $withRelations = ['user', 'place_in_challange', 'place'];
foreach ($this->guessRepository->getAllInChallenge($challenge, $withRelations) as $guess) { foreach ($this->guessRepository->getAllInChallenge($challenge, $withRelations) as $guess) {
$round = $guess->getPlaceInChallenge()->getRound(); $round = $guess->getPlaceInChallenge()->getRound();
@ -187,7 +187,7 @@ class GameFlowController implements IAuthenticationRequired
$prevRound = $currentRound - 1; $prevRound = $currentRound - 1;
if ($prevRound >= 0) { if ($prevRound >= 0) {
foreach ($this->guessRepository->getAllInChallengeByRound($prevRound, $challenge, [User::class]) as $guess) { foreach ($this->guessRepository->getAllInChallengeByRound($prevRound, $challenge, ['user']) as $guess) {
if ($guess->getUser()->getId() != $userId) { if ($guess->getUser()->getId() != $userId) {
$response['allResults'][] = [ $response['allResults'][] = [
'userName' => $guess->getUser()->getDisplayName(), 'userName' => $guess->getUser()->getDisplayName(),
@ -216,7 +216,7 @@ class GameFlowController implements IAuthenticationRequired
$session = \Container::$request->session(); $session = \Container::$request->session();
$userId = $session->get('userId'); $userId = $session->get('userId');
$challengeToken_str = \Container::$request->query('challengeToken'); $challengeToken_str = \Container::$request->query('challengeToken');
$userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, [Challenge::class]); $userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, ['challenge']);
if (!isset($userInChallenge)) { if (!isset($userInChallenge)) {
return new JsonContent(['error' => 'game_not_found']); return new JsonContent(['error' => 'game_not_found']);
@ -337,7 +337,7 @@ class GameFlowController implements IAuthenticationRequired
$session = \Container::$request->session(); $session = \Container::$request->session();
$userId = $session->get('userId'); $userId = $session->get('userId');
$challengeToken_str = \Container::$request->query('challengeToken'); $challengeToken_str = \Container::$request->query('challengeToken');
$userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, [Challenge::class]); $userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, ['challenge']);
if (!isset($userInChallenge)) { if (!isset($userInChallenge)) {
return new JsonContent(['error' => 'game_not_found']); return new JsonContent(['error' => 'game_not_found']);
@ -345,7 +345,7 @@ class GameFlowController implements IAuthenticationRequired
$challenge = $userInChallenge->getChallenge(); $challenge = $userInChallenge->getChallenge();
$currentRound = $userInChallenge->getCurrentRound(); $currentRound = $userInChallenge->getCurrentRound();
$currentPlaceInChallenge = $this->placeInChallengeRepository->getByRoundInChallenge($currentRound, $challenge, [Place::class, Map::class]); $currentPlaceInChallenge = $this->placeInChallengeRepository->getByRoundInChallenge($currentRound, $challenge, ['place', 'map']);
$currentPlace = $currentPlaceInChallenge->getPlace(); $currentPlace = $currentPlaceInChallenge->getPlace();
$map = $currentPlace->getMap(); $map = $currentPlace->getMap();

View File

@ -218,7 +218,7 @@ class MapAdminController implements IAuthenticationRequired, ISecured
\Container::$persistentDataManager->deleteFromDb($userInChallenge); \Container::$persistentDataManager->deleteFromDb($userInChallenge);
} }
foreach ($this->guessRepository->getAllInChallenge($challenge, [PlaceInChallenge::class]) as $guess) { foreach ($this->guessRepository->getAllInChallenge($challenge, ['place_in_challange']) as $guess) {
\Container::$persistentDataManager->deleteFromDb($guess); \Container::$persistentDataManager->deleteFromDb($guess);
} }

View File

@ -53,7 +53,7 @@ class GuessRepository
public function getAllInChallenge(Challenge $challenge, array $withRelations = []): Generator public function getAllInChallenge(Challenge $challenge, array $withRelations = []): Generator
{ {
if (count($withRelations)) { if (count($withRelations)) {
$necessaryRelations = [PlaceInChallenge::class]; $necessaryRelations = ['place_in_challenge'];
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations)); $withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
} }
@ -67,7 +67,7 @@ class GuessRepository
public function getAllInChallengeByRound(int $round, Challenge $challenge, array $withRelations = []): Generator public function getAllInChallengeByRound(int $round, Challenge $challenge, array $withRelations = []): Generator
{ {
if (count($withRelations)) { if (count($withRelations)) {
$necessaryRelations = [PlaceInChallenge::class]; $necessaryRelations = ['place_in_challenge'];
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations)); $withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
} }

View File

@ -29,7 +29,7 @@ class UserInChallengeRepository
$select = new Select(\Container::$dbConnection); $select = new Select(\Container::$dbConnection);
$select->where('challenge_id', '=', $challenge->getId()); $select->where('challenge_id', '=', $challenge->getId());
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, UserInChallenge::class, true, [User::class]); yield from \Container::$persistentDataManager->selectMultipleFromDb($select, UserInChallenge::class, true, ['user']);
} }
public function getByUserIdAndChallenge(int $userId, Challenge $challenge): ?UserInChallenge public function getByUserIdAndChallenge(int $userId, Challenge $challenge): ?UserInChallenge
@ -44,7 +44,7 @@ class UserInChallengeRepository
public function getByUserIdAndToken(int $userId, string $token_str, array $withRelations = []): ?UserInChallenge public function getByUserIdAndToken(int $userId, string $token_str, array $withRelations = []): ?UserInChallenge
{ {
if (count($withRelations)) { if (count($withRelations)) {
$necessaryRelations = [Challenge::class]; $necessaryRelations = ['challange'];
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations)); $withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
} }