1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\GameRating\Communication\Controller; |
4
|
|
|
|
5
|
|
|
use App\GameBetting\Business\Games\UserPastGamesInterface; |
6
|
|
|
use App\GameRating\Business\GameRatingFacadeInterface; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
8
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
9
|
|
|
|
10
|
|
|
class UserRating extends Controller |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var GameRatingFacadeInterface |
14
|
|
|
*/ |
15
|
|
|
private $gameRatingFacade; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var UserPastGamesInterface |
19
|
|
|
*/ |
20
|
|
|
private $userPastGames; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param GameRatingFacadeInterface $gameRatingFacade |
24
|
|
|
* @param UserPastGamesInterface $userPastGames |
25
|
|
|
*/ |
26
|
|
|
public function __construct(GameRatingFacadeInterface $gameRatingFacade, UserPastGamesInterface $userPastGames) |
27
|
|
|
{ |
28
|
|
|
$this->gameRatingFacade = $gameRatingFacade; |
29
|
|
|
$this->userPastGames = $userPastGames; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @Route("/users/", name="game_rating_users") |
35
|
|
|
*/ |
36
|
|
|
public function users() |
37
|
|
|
{ |
38
|
|
|
$userScoreWithPositions = $this->gameRatingFacade->getUserScoreWithPosition(); |
39
|
|
|
return $this->render( |
40
|
|
|
'game_rating/user_rating/users.html.twig', |
41
|
|
|
[ |
42
|
|
|
'userScoreWithPositions' => $userScoreWithPositions, |
43
|
|
|
'myUserId' => $this->getUser()->getId() |
44
|
|
|
] |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @Route("/myInfo/", name="game_rating_my_info") |
50
|
|
|
*/ |
51
|
|
|
public function myInfo() |
52
|
|
|
{ |
53
|
|
|
$userScoreWithPositions = $this->gameRatingFacade->getUserScoreWithPosition(); |
54
|
|
|
$myScoreWithPositions = false; |
55
|
|
|
$userId = $this->getUser()->getId(); |
56
|
|
|
foreach ($userScoreWithPositions as $userScoreWithPosition) { |
57
|
|
|
if ($userScoreWithPosition->getUserScore()->getUser()->getId() === $userId) { |
58
|
|
|
$myScoreWithPositions = $userScoreWithPosition; |
59
|
|
|
break; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
return $this->render( |
63
|
|
|
'game_rating/user_rating/my_info.html.twig', |
64
|
|
|
[ |
65
|
|
|
'myScoreWithPositions' => $myScoreWithPositions, |
66
|
|
|
] |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @Route("/ratingTop3/", name="game_rating_top_three") |
72
|
|
|
*/ |
73
|
|
|
public function ratingTopThree() |
74
|
|
|
{ |
75
|
|
|
$userScoreWithPositions = $this->gameRatingFacade->getUserScoreWithPosition(); |
76
|
|
|
$topTree = []; |
77
|
|
|
|
78
|
|
|
for ($i = 0; $i < 3; $i++) { |
79
|
|
|
if (isset($userScoreWithPositions[$i])) { |
80
|
|
|
$topTree[] = $userScoreWithPositions[$i]; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $this->render( |
85
|
|
|
'game_rating/user_rating/top_three.html.twig', |
86
|
|
|
[ |
87
|
|
|
'userScoreWithPositions' => $topTree, |
88
|
|
|
] |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
} |