1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright 2014-2016 Arnaud Bienvenu |
4
|
|
|
* |
5
|
|
|
* This file is part of Kyela. |
6
|
|
|
|
7
|
|
|
* Kyela is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
|
12
|
|
|
* Kyela is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with Kyela. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Abienvenu\KyelaBundle\Entity; |
23
|
|
|
|
24
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
25
|
|
|
use Doctrine\ORM\Mapping as ORM; |
26
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @ORM\Entity |
30
|
|
|
* @ORM\Table(name="Participant") |
31
|
|
|
*/ |
32
|
|
|
class Participant extends Entity |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @ORM\Id |
36
|
|
|
* @ORM\Column(type="integer") |
37
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
38
|
|
|
*/ |
39
|
|
|
private $id; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @ORM\Column(type="string", length=100) |
43
|
|
|
* @Assert\NotBlank() |
44
|
|
|
*/ |
45
|
|
|
private $name; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var integer |
49
|
|
|
* |
50
|
|
|
* @ORM\Column(name="priority", type="integer") |
51
|
|
|
*/ |
52
|
|
|
private $priority = 0; |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @ORM\OneToMany(targetEntity="Participation", mappedBy="participant", cascade={"remove"}) |
57
|
|
|
*/ |
58
|
|
|
private $participations; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @ORM\ManyToOne(targetEntity="Poll", inversedBy="participants") |
62
|
|
|
*/ |
63
|
|
|
private $poll; |
64
|
|
|
|
65
|
|
|
public function __construct() |
66
|
|
|
{ |
67
|
|
|
$this->participations = new ArrayCollection(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function __toString() |
74
|
|
|
{ |
75
|
|
|
return $this->name; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get id |
80
|
|
|
* |
81
|
|
|
* @return integer |
82
|
|
|
*/ |
83
|
|
|
public function getId() |
84
|
|
|
{ |
85
|
|
|
return $this->id; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Set name |
90
|
|
|
* |
91
|
|
|
* @param string $name |
92
|
|
|
* @return Participant |
93
|
|
|
*/ |
94
|
|
|
public function setName($name) |
95
|
|
|
{ |
96
|
|
|
$this->name = $name; |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Get name |
103
|
|
|
* |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function getName() |
107
|
|
|
{ |
108
|
|
|
return $this->name; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return mixed |
113
|
|
|
*/ |
114
|
|
|
public function getPriority() |
115
|
|
|
{ |
116
|
|
|
return $this->priority; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param mixed $priority |
121
|
|
|
*/ |
122
|
|
|
public function setPriority($priority) |
123
|
|
|
{ |
124
|
|
|
$this->priority = $priority; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Add participations |
129
|
|
|
* |
130
|
|
|
* @param \Abienvenu\KyelaBundle\Entity\Participation $participations |
131
|
|
|
* @return Participant |
132
|
|
|
*/ |
133
|
|
|
public function addParticipation(Participation $participations) |
134
|
|
|
{ |
135
|
|
|
$this->participations[] = $participations; |
136
|
|
|
|
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Remove participations |
142
|
|
|
* |
143
|
|
|
* @param Participation $participations |
144
|
|
|
*/ |
145
|
|
|
public function removeParticipation(Participation $participations) |
146
|
|
|
{ |
147
|
|
|
$this->participations->removeElement($participations); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Get participations |
152
|
|
|
* |
153
|
|
|
* @return \Doctrine\Common\Collections\Collection |
154
|
|
|
*/ |
155
|
|
|
public function getParticipations() |
156
|
|
|
{ |
157
|
|
|
return $this->participations; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Set poll |
162
|
|
|
* |
163
|
|
|
* @param Poll $poll |
164
|
|
|
* @return Participant |
165
|
|
|
*/ |
166
|
|
|
public function setPoll(Poll $poll = null) |
167
|
|
|
{ |
168
|
|
|
$this->poll = $poll; |
169
|
|
|
|
170
|
|
|
return $this; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Get poll |
175
|
|
|
* |
176
|
|
|
* @return Poll |
177
|
|
|
*/ |
178
|
|
|
public function getPoll() |
179
|
|
|
{ |
180
|
|
|
return $this->poll; |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|