/** * @param Request $request * @param $username * @throws NotFoundHttpException * @return array * * @Route("/evolution-games/profile/{username}", name="eg_profile") * @Route("/evolution-games/profile-id/{username}", name="eg_profile_id") * @Template */ public function profileAction(Request $request, $username) { return $this->redirectRoute('eg_scholarship'); // We're apparently not using this anymore. Let's put this here just in // case we missed any links. return $this->redirectRoute('user_profile', ['username' => $username]); /* * i. Public Profile page will display gamer profile in addition to: Games played * with win/loss stats. Total number of points in the competition (report card), and global * ranking. In addition, we can display their picture/avatar, their bio/story. Facebook * posting functionality (but it will show only to the player, player must be logged in * GotChosen to see). * * ii. When player is logged in, it will display the number of remaining plays for the day, and * bonus plays (if any) along with pending challenge requests/challenge initiations. It will * also Display the history of the rounds: the game played, the day played, and the score. */ $route = $request->attributes->get('_route'); /** @var UserManager $userManager */ $userManager = $this->get('fos_user.user_manager'); /** @var User $user */ if ($route == 'eg_profile') { $user = $userManager->findUserByUsername($username); // We're probably not supposed to do this, but ... if (!$user) { $user = $userManager->findUserBy(['username' => $username]); } } else { $user = $userManager->findUserBy(['id' => $username]); } if (!$user || !$user->isEnabled()) { throw new NotFoundHttpException('User not found'); } $this->repo('User')->precacheProperties($user); /** @var EGPlayerStatsRepository $statsRepo */ $statsRepo = $this->repo('EGPlayerStats'); $reportCard = $this->get('gotchosen.report_card_manager')->getForUser($user); $gameResults = $this->repo('EGGameResult')->findResultsForProfile($user, date('Y-m')); $gameSessions = []; foreach (Dates::rangeMonths(date('Y-m'), -2) as $month) { $gameSessions["{$month}-01"] = $statsRepo->findPlaySessions($user, $month); } return ['user' => $user, 'reportCard' => $reportCard, 'gameSessions' => $gameSessions, 'gameResults' => $gameResults]; }