1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* Created by PhpStorm. |
5
|
|
|
* User: benedikt |
6
|
|
|
* Date: 10/20/17 |
7
|
|
|
* Time: 12:30 PM |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Tfboe\FmLib\Entity\Traits; |
11
|
|
|
|
12
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
13
|
|
|
use Doctrine\Common\Collections\Collection; |
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
15
|
|
|
use Tfboe\FmLib\Entity\CompetitionInterface; |
16
|
|
|
use Tfboe\FmLib\Entity\Helpers\NameEntity; |
17
|
|
|
use Tfboe\FmLib\Entity\Helpers\UUIDEntity; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Trait Team |
22
|
|
|
* @package Tfboe\FmLib\Entity\Traits |
23
|
|
|
*/ |
24
|
|
|
trait Team |
25
|
|
|
{ |
26
|
|
|
use UUIDEntity; |
27
|
|
|
use NameEntity; |
28
|
|
|
|
29
|
|
|
//<editor-fold desc="Fields"> |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ORM\ManyToMany(targetEntity="\Tfboe\FmLib\Entity\PlayerInterface", indexBy="playerId") |
33
|
|
|
* @ORM\JoinTable(name="relation__team_players", |
34
|
|
|
* joinColumns={@ORM\JoinColumn(name="team_id", referencedColumnName="id")}, |
35
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="player_id", referencedColumnName="player_id")} |
36
|
|
|
* ) |
37
|
|
|
* |
38
|
|
|
* @var Collection|Player[] |
39
|
|
|
*/ |
40
|
|
|
private $players; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @ORM\ManyToOne(targetEntity="\Tfboe\FmLib\Entity\CompetitionInterface", inversedBy="teams") |
44
|
|
|
* @var CompetitionInterface |
45
|
|
|
*/ |
46
|
|
|
private $competition; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @ORM\Column(type="integer") |
50
|
|
|
* @var int |
51
|
|
|
*/ |
52
|
|
|
private $rank; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @ORM\Column(type="integer") |
56
|
|
|
* @var int |
57
|
|
|
*/ |
58
|
|
|
private $startNumber; |
59
|
|
|
//</editor-fold desc="Fields"> |
60
|
|
|
|
61
|
|
|
//<editor-fold desc="Constructor"> |
62
|
|
|
//</editor-fold desc="Constructor"> |
63
|
|
|
|
64
|
|
|
//<editor-fold desc="Public Methods"> |
65
|
|
|
/** |
66
|
|
|
* @return CompetitionInterface |
67
|
|
|
*/ |
68
|
|
|
public function getCompetition(): CompetitionInterface |
69
|
|
|
{ |
70
|
|
|
return $this->competition; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return Player[]|Collection |
75
|
|
|
*/ |
76
|
|
|
public function getPlayers() |
77
|
|
|
{ |
78
|
|
|
return $this->players; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return int |
83
|
|
|
*/ |
84
|
|
|
public function getRank(): int |
85
|
|
|
{ |
86
|
|
|
return $this->rank; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return int |
91
|
|
|
*/ |
92
|
|
|
public function getStartNumber(): int |
93
|
|
|
{ |
94
|
|
|
return $this->startNumber; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param CompetitionInterface $competition |
99
|
|
|
*/ |
100
|
|
|
public function setCompetition(CompetitionInterface $competition) |
101
|
|
|
{ |
102
|
|
|
if ($this->competition !== null) { |
103
|
|
|
$this->competition->getTeams()->remove($this->getStartNumber()); |
104
|
|
|
} |
105
|
|
|
$this->competition = $competition; |
106
|
|
|
$this->competition->getTeams()->set($this->getStartNumber(), $this); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param int $rank |
111
|
|
|
*/ |
112
|
|
|
public function setRank(int $rank) |
113
|
|
|
{ |
114
|
|
|
$this->rank = $rank; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param int $startNumber |
119
|
|
|
*/ |
120
|
|
|
public function setStartNumber(int $startNumber) |
121
|
|
|
{ |
122
|
|
|
$this->startNumber = $startNumber; |
123
|
|
|
} |
124
|
|
|
//</editor-fold desc="Public Methods"> |
125
|
|
|
|
126
|
|
|
//<editor-fold desc="Protected Final Methods"> |
127
|
|
|
/** |
128
|
|
|
* Team init |
129
|
|
|
*/ |
130
|
|
|
protected final function init() |
131
|
|
|
{ |
132
|
|
|
$this->players = new ArrayCollection(); |
133
|
|
|
$this->name = ""; |
134
|
|
|
} |
135
|
|
|
//</editor-fold desc="Protected Final Methods"> |
136
|
|
|
} |