getUser(); $game = null; if ($user) { $game = $gameRepository->findActiveForUser($user); } else { $gameId = $request->getSession()->get('current_game_id'); if ($gameId) { $game = $gameRepository->find($gameId); if (!$game || $game->getStatus() !== Game::STATUS_IN_PROGRESS) { $request->getSession()->remove('current_game_id'); $game = null; } } } if (!$game) { return $this->render('homepage/index.html.twig', [ 'game' => null, ]); } $gridData = $gridGenerator->computeGridData($game); return $this->render('homepage/index.html.twig', [ 'game' => $game, 'grid' => $gridData['grid'], 'width' => $gridData['width'], 'middle' => $gridData['middle'], ]); } }