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
|
|
|
use Tfboe\FmLib\Entity\TeamMembershipInterface; |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Trait Team |
23
|
|
|
* @package Tfboe\FmLib\Entity\Traits |
24
|
|
|
*/ |
25
|
|
|
trait Team |
26
|
|
|
{ |
27
|
|
|
use UUIDEntity; |
28
|
|
|
use NameEntity; |
29
|
|
|
|
30
|
|
|
//<editor-fold desc="Fields"> |
31
|
|
|
/** |
32
|
|
|
* @ORM\OneToMany(targetEntity="\Tfboe\FmLib\Entity\TeamMembershipInterface", mappedBy="team", indexBy="id") |
33
|
|
|
* @var Collection|TeamMembershipInterface[] |
34
|
|
|
*/ |
35
|
|
|
private $memberships; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return Collection|TeamMembershipInterface[] |
39
|
|
|
*/ |
40
|
|
|
public function getMemberships(): Collection |
41
|
|
|
{ |
42
|
|
|
return $this->memberships; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ORM\ManyToOne(targetEntity="\Tfboe\FmLib\Entity\CompetitionInterface", inversedBy="teams") |
47
|
|
|
* @var CompetitionInterface |
48
|
|
|
*/ |
49
|
|
|
private $competition; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @ORM\Column(name="`rank`", type="integer") |
53
|
|
|
* @var int |
54
|
|
|
*/ |
55
|
|
|
private $rank; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @ORM\Column(type="integer") |
59
|
|
|
* @var int |
60
|
|
|
*/ |
61
|
|
|
private $startNumber; |
62
|
|
|
//</editor-fold desc="Fields"> |
63
|
|
|
|
64
|
|
|
//<editor-fold desc="Constructor"> |
65
|
|
|
//</editor-fold desc="Constructor"> |
66
|
|
|
|
67
|
|
|
//<editor-fold desc="Public Methods"> |
68
|
|
|
/** |
69
|
|
|
* @return CompetitionInterface |
70
|
|
|
*/ |
71
|
|
|
public function getCompetition(): CompetitionInterface |
72
|
|
|
{ |
73
|
|
|
return $this->competition; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return int |
78
|
|
|
*/ |
79
|
|
|
public function getRank(): int |
80
|
|
|
{ |
81
|
|
|
return $this->rank; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return int |
86
|
|
|
*/ |
87
|
|
|
public function getStartNumber(): int |
88
|
|
|
{ |
89
|
|
|
return $this->startNumber; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param CompetitionInterface $competition |
94
|
|
|
*/ |
95
|
|
|
public function setCompetition(CompetitionInterface $competition) |
96
|
|
|
{ |
97
|
|
|
if ($this->competition !== null) { |
98
|
|
|
$this->competition->getTeams()->remove($this->getStartNumber()); |
99
|
|
|
} |
100
|
|
|
$this->competition = $competition; |
101
|
|
|
$this->competition->getTeams()->set($this->getStartNumber(), $this); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param int $rank |
106
|
|
|
*/ |
107
|
|
|
public function setRank(int $rank) |
108
|
|
|
{ |
109
|
|
|
$this->rank = $rank; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param int $startNumber |
114
|
|
|
*/ |
115
|
|
|
public function setStartNumber(int $startNumber) |
116
|
|
|
{ |
117
|
|
|
$this->startNumber = $startNumber; |
118
|
|
|
} |
119
|
|
|
//</editor-fold desc="Public Methods"> |
120
|
|
|
|
121
|
|
|
//<editor-fold desc="Protected Final Methods"> |
122
|
|
|
/** |
123
|
|
|
* Team init |
124
|
|
|
*/ |
125
|
|
|
protected final function init() |
126
|
|
|
{ |
127
|
|
|
$this->memberships = new ArrayCollection(); |
128
|
|
|
$this->name = ""; |
129
|
|
|
} |
130
|
|
|
//</editor-fold desc="Protected Final Methods"> |
131
|
|
|
} |