1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* Created by PhpStorm. |
5
|
|
|
* User: benedikt |
6
|
|
|
* Date: 10/15/17 |
7
|
|
|
* Time: 10:57 AM |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Tfboe\FmLib\Entity\Traits; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
14
|
|
|
use Doctrine\Common\Collections\Collection; |
15
|
|
|
use Doctrine\ORM\Mapping as ORM; |
16
|
|
|
use Tfboe\FmLib\Entity\CompetitionInterface; |
17
|
|
|
use Tfboe\FmLib\Entity\Helpers\NameEntity; |
18
|
|
|
use Tfboe\FmLib\Entity\Helpers\TournamentHierarchyInterface; |
19
|
|
|
use Tfboe\FmLib\Entity\MatchInterface; |
20
|
|
|
use Tfboe\FmLib\Entity\QualificationSystem; |
21
|
|
|
use Tfboe\FmLib\Entity\Ranking; |
22
|
|
|
use Tfboe\FmLib\Helpers\Level; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Trait Phase |
26
|
|
|
* @package Tfboe\FmLib\Entity\Traits |
27
|
|
|
*/ |
28
|
|
|
trait Phase |
29
|
|
|
{ |
30
|
|
|
use NameEntity; |
31
|
|
|
|
32
|
|
|
//<editor-fold desc="Fields"> |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @ORM\ManyToOne(targetEntity="\Tfboe\FmLib\Entity\CompetitionInterface", inversedBy="phases") |
36
|
|
|
* @var CompetitionInterface |
37
|
|
|
*/ |
38
|
|
|
private $competition; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @ORM\Column(type="integer") |
42
|
|
|
* @var int |
43
|
|
|
*/ |
44
|
|
|
private $phaseNumber; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @ORM\OneToMany(targetEntity="\Tfboe\FmLib\Entity\QualificationSystem", mappedBy="nextPhase") |
48
|
|
|
* @var Collection|QualificationSystem[] |
49
|
|
|
*/ |
50
|
|
|
private $preQualifications; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @ORM\OneToMany(targetEntity="\Tfboe\FmLib\Entity\QualificationSystem", mappedBy="previousPhase") |
54
|
|
|
* @var Collection|QualificationSystem[] |
55
|
|
|
*/ |
56
|
|
|
private $postQualifications; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @ORM\OneToMany(targetEntity="\Tfboe\FmLib\Entity\Ranking", mappedBy="group", indexBy="uniqueRank") |
60
|
|
|
* @var Collection|Ranking[] |
61
|
|
|
*/ |
62
|
|
|
private $rankings; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @ORM\OneToMany(targetEntity="\Tfboe\FmLib\Entity\MatchInterface", mappedBy="phase", indexBy="matchNumber") |
66
|
|
|
* @var Collection|MatchInterface[] |
67
|
|
|
*/ |
68
|
|
|
private $matches; |
69
|
|
|
//</editor-fold desc="Fields"> |
70
|
|
|
|
71
|
|
|
//<editor-fold desc="Public Methods"> |
72
|
|
|
/** |
73
|
|
|
* @inheritDoc |
74
|
|
|
*/ |
75
|
|
|
public function getChildren(): Collection |
76
|
|
|
{ |
77
|
|
|
return $this->getMatches(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return CompetitionInterface |
82
|
|
|
*/ |
83
|
|
|
public function getCompetition(): CompetitionInterface |
84
|
|
|
{ |
85
|
|
|
return $this->competition; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @inheritDoc |
90
|
|
|
*/ |
91
|
|
|
public function getLevel(): int |
92
|
|
|
{ |
93
|
|
|
return Level::PHASE; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @inheritDoc |
98
|
|
|
*/ |
99
|
|
|
public function getLocalIdentifier() |
100
|
|
|
{ |
101
|
|
|
return $this->getPhaseNumber(); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return MatchInterface[]|Collection |
106
|
|
|
*/ |
107
|
|
|
public function getMatches() |
108
|
|
|
{ |
109
|
|
|
return $this->matches; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @inheritDoc |
114
|
|
|
*/ |
115
|
|
|
public function getParent(): ?TournamentHierarchyInterface |
116
|
|
|
{ |
117
|
|
|
return $this->getCompetition(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return int |
122
|
|
|
*/ |
123
|
|
|
public function getPhaseNumber(): int |
124
|
|
|
{ |
125
|
|
|
return $this->phaseNumber; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return QualificationSystem[]|Collection |
130
|
|
|
*/ |
131
|
|
|
public function getPostQualifications(): Collection |
132
|
|
|
{ |
133
|
|
|
return $this->postQualifications; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return QualificationSystem[]|Collection |
138
|
|
|
*/ |
139
|
|
|
public function getPreQualifications(): Collection |
140
|
|
|
{ |
141
|
|
|
return $this->preQualifications; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return Ranking[]|Collection |
146
|
|
|
*/ |
147
|
|
|
public function getRankings() |
148
|
|
|
{ |
149
|
|
|
return $this->rankings; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Competition constructor. |
154
|
|
|
*/ |
155
|
|
|
public function init() |
156
|
|
|
{ |
157
|
|
|
$this->preQualifications = new ArrayCollection(); |
158
|
|
|
$this->postQualifications = new ArrayCollection(); |
159
|
|
|
$this->name = ''; |
160
|
|
|
$this->rankings = new ArrayCollection(); |
161
|
|
|
$this->matches = new ArrayCollection(); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param CompetitionInterface $competition |
166
|
|
|
*/ |
167
|
|
|
public function setCompetition(CompetitionInterface $competition) |
168
|
|
|
{ |
169
|
|
|
if ($this->competition !== null) { |
170
|
|
|
$this->competition->getPhases()->remove($this->getPhaseNumber()); |
171
|
|
|
} |
172
|
|
|
$this->competition = $competition; |
173
|
|
|
$competition->getPhases()->set($this->getPhaseNumber(), $this); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param int $phaseNumber |
178
|
|
|
*/ |
179
|
|
|
public function setPhaseNumber(int $phaseNumber) |
180
|
|
|
{ |
181
|
|
|
$this->phaseNumber = $phaseNumber; |
182
|
|
|
} |
183
|
|
|
//</editor-fold desc="Public Methods"> |
184
|
|
|
} |