1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Ranking\Provider\Player; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Exception\ORMException; |
6
|
|
|
|
7
|
|
|
class PlayerRankingProvider |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @param array $options |
11
|
|
|
* @return array |
12
|
|
|
* @throws ORMException |
13
|
|
|
*/ |
14
|
|
|
public function getRankingPointChart(array $options = []): array |
15
|
|
|
{ |
16
|
|
|
return $this->getRanking('rankPointChart', $options); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param array $options |
21
|
|
|
* @return array |
22
|
|
|
* @throws ORMException |
23
|
|
|
*/ |
24
|
|
|
public function getRankingPointGame(array $options = []): array |
25
|
|
|
{ |
26
|
|
|
return $this->getRanking('rankPointGame', $options); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param array $options |
31
|
|
|
* @return array |
32
|
|
|
* @throws ORMException |
33
|
|
|
*/ |
34
|
|
|
public function getRankingMedals(array $options = []): array |
35
|
|
|
{ |
36
|
|
|
return $this->getRanking('rankMedal', $options); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param array $options |
41
|
|
|
* @return array |
42
|
|
|
* @throws ORMException |
43
|
|
|
*/ |
44
|
|
|
public function getRankingBadge(array $options = []): array |
45
|
|
|
{ |
46
|
|
|
return $this->getRanking('rankBadge', $options); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param array $options |
51
|
|
|
* @return array |
52
|
|
|
* @throws ORMException |
53
|
|
|
*/ |
54
|
|
|
public function getRankingCup(array $options = []): array |
55
|
|
|
{ |
56
|
|
|
return $this->getRanking('rankCup', $options); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param array $options |
61
|
|
|
* @return array |
62
|
|
|
* @throws ORMException |
63
|
|
|
*/ |
64
|
|
|
public function getRankingProof(array $options = []): array |
65
|
|
|
{ |
66
|
|
|
return $this->getRanking('rankProof', $options); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param string $column |
71
|
|
|
* @param array $options |
72
|
|
|
* @return array |
73
|
|
|
* @throws ORMException |
74
|
|
|
*/ |
75
|
|
|
private function getRanking(string $column = 'rankPointChart', array $options = []): array |
76
|
|
|
{ |
77
|
|
|
$maxRank = $options['maxRank'] ?? 100; |
78
|
|
|
$limit = $options['limit'] ?? null; |
79
|
|
|
$player = $this->getPlayer(); |
|
|
|
|
80
|
|
|
$team = !empty($options['idTeam']) ? $this->em->getReference('VideoGamesRecords\CoreBundle\Entity\Team', $options['idTeam']) : null; |
|
|
|
|
81
|
|
|
|
82
|
|
|
$query = $this->em->createQueryBuilder() |
83
|
|
|
->select('p') |
84
|
|
|
->from('VideoGamesRecords\CoreBundle\Entity\Player', 'p') |
85
|
|
|
->leftJoin('p.team', 't') |
86
|
|
|
->addSelect('t') |
87
|
|
|
->leftJoin('p.country', 'c') |
88
|
|
|
->addSelect('c') |
89
|
|
|
->leftJoin('c.translations', 'trans') |
90
|
|
|
->addSelect('trans') |
91
|
|
|
->where("p.$column != 0") |
92
|
|
|
->orderBy("p.$column"); |
93
|
|
|
|
94
|
|
|
if ($team !== null) { |
95
|
|
|
$query->andWhere('(p.team = :team)') |
96
|
|
|
->setParameter('team', $team); |
97
|
|
|
} elseif (($maxRank !== null) && ($player !== null)) { |
98
|
|
|
$query->andWhere("(p.$column <= :maxRank OR p = :player)") |
99
|
|
|
->setParameter('maxRank', $maxRank) |
100
|
|
|
->setParameter('player', $player); |
101
|
|
|
} else { |
102
|
|
|
$query->andWhere("p.$column <= :maxRank") |
103
|
|
|
->setParameter('maxRank', $maxRank); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
if (null !== $limit) { |
107
|
|
|
$query->setMaxResults($limit); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $query->getQuery()->getResult(); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.