feat: extract game config from POST and pass eligible AwardTypes to template
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,40 @@ class GameController extends AbstractController
|
||||
return $this->redirectToRoute('app_homepage');
|
||||
}
|
||||
|
||||
$game = $generator->generate($user);
|
||||
// Build config from form parameters
|
||||
$config = [];
|
||||
|
||||
if ($user && $request->request->getBoolean('watched_only')) {
|
||||
$config['watchedOnly'] = true;
|
||||
}
|
||||
|
||||
$hintTypes = [];
|
||||
if ($request->request->getBoolean('hint_film', true)) {
|
||||
$hintTypes[] = 'film';
|
||||
}
|
||||
if ($request->request->getBoolean('hint_character', true)) {
|
||||
$hintTypes[] = 'character';
|
||||
}
|
||||
if ($request->request->getBoolean('hint_award', true)) {
|
||||
$hintTypes[] = 'award';
|
||||
}
|
||||
if (empty($hintTypes)) {
|
||||
$hintTypes = ['film', 'character', 'award'];
|
||||
}
|
||||
$config['hintTypes'] = $hintTypes;
|
||||
|
||||
/** @var list<string> $awardTypeIds */
|
||||
$awardTypeIds = $request->request->all('award_types');
|
||||
if (!empty($awardTypeIds) && in_array('award', $hintTypes)) {
|
||||
$config['awardTypeIds'] = array_map('intval', $awardTypeIds);
|
||||
}
|
||||
|
||||
$game = $generator->generate($user, $config);
|
||||
|
||||
if ($game === null) {
|
||||
$this->addFlash('error', 'Impossible de générer une grille avec ces paramètres. Essayez avec des critères moins restrictifs.');
|
||||
return $this->redirectToRoute('app_homepage');
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
$request->getSession()->set('current_game_id', $game->getId());
|
||||
|
||||
Reference in New Issue
Block a user