1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
8
|
|
|
use Gedmo\Blameable\Traits\BlameableEntity; |
9
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
10
|
|
|
use AppBundle\Traits\TimestampableTrait; |
11
|
|
|
use AppBundle\Traits\DeletedByTrait; |
12
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
13
|
|
|
use JMS\Serializer\Annotation\Expose; |
14
|
|
|
use JMS\Serializer\Annotation\Type; |
15
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface; |
16
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @ORM\Table(name="roles") |
20
|
|
|
* @ORM\Entity |
21
|
|
|
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) |
22
|
|
|
* @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\RoleTranslation") |
23
|
|
|
* @ExclusionPolicy("all") |
24
|
|
|
*/ |
25
|
|
|
class Role extends AbstractPersonalTranslatable implements TranslatableInterface |
26
|
|
|
{ |
27
|
|
|
use TimestampableTrait, BlameableEntity, DeletedByTrait; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var integer |
31
|
|
|
* |
32
|
|
|
* @ORM\Column(name="id", type="integer") |
33
|
|
|
* @ORM\Id |
34
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
35
|
|
|
*/ |
36
|
|
|
private $id; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var string |
40
|
|
|
* @Gedmo\Translatable |
41
|
|
|
* @Assert\NotBlank() |
42
|
|
|
* @ORM\Column(type="string", length=255) |
43
|
|
|
* @Type("string") |
44
|
|
|
* @Expose |
45
|
|
|
*/ |
46
|
|
|
private $title; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
* @Gedmo\Translatable |
51
|
|
|
* @ORM\Column(type="text", nullable=true) |
52
|
|
|
* @Type("string") |
53
|
|
|
* @Expose |
54
|
|
|
*/ |
55
|
|
|
private $description; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var Performance |
59
|
|
|
* |
60
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Performance", inversedBy="roles") |
61
|
|
|
* @Expose() |
62
|
|
|
*/ |
63
|
|
|
private $performance; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var Employee |
67
|
|
|
* |
68
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Employee", inversedBy="roles") |
69
|
|
|
* @Type("AppBundle\Entity\Employee") |
70
|
|
|
* @Expose |
71
|
|
|
*/ |
72
|
|
|
private $employee; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @Gedmo\Slug(fields={"title"}) |
76
|
|
|
* @ORM\Column(name="slug", type="string", length=255) |
77
|
|
|
* @Type("string") |
78
|
|
|
* @Expose |
79
|
|
|
*/ |
80
|
|
|
private $slug; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var ArrayCollection |
84
|
|
|
* |
85
|
|
|
* @ORM\OneToMany( |
86
|
|
|
* targetEntity="AppBundle\Entity\Translations\RoleTranslation", |
87
|
|
|
* mappedBy="object", |
88
|
|
|
* cascade={"persist", "remove"} |
89
|
|
|
* ) |
90
|
|
|
*/ |
91
|
|
|
protected $translations; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Unset translations |
95
|
|
|
* |
96
|
|
|
* @return Role |
97
|
|
|
*/ |
98
|
2 |
|
public function unsetTranslations() |
99
|
|
|
{ |
100
|
2 |
|
$this->translations = null; |
101
|
|
|
|
102
|
2 |
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Get id |
107
|
|
|
* |
108
|
|
|
* @return integer |
109
|
|
|
*/ |
110
|
2 |
|
public function getId() |
111
|
|
|
{ |
112
|
2 |
|
return $this->id; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get title |
117
|
|
|
* |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
5 |
|
public function getTitle() |
121
|
|
|
{ |
122
|
5 |
|
return $this->title; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Set title |
127
|
|
|
* |
128
|
|
|
* @param string $title |
129
|
|
|
* @return Role |
130
|
|
|
*/ |
131
|
|
|
public function setTitle($title) |
132
|
|
|
{ |
133
|
|
|
$this->title = $title; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Get description |
140
|
|
|
* |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
3 |
|
public function getDescription() |
144
|
|
|
{ |
145
|
3 |
|
return $this->description; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set description |
150
|
|
|
* |
151
|
|
|
* @param string $description |
152
|
|
|
* @return Role |
153
|
|
|
*/ |
154
|
|
|
public function setDescription($description) |
155
|
|
|
{ |
156
|
|
|
$this->description = $description; |
157
|
|
|
|
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Get slug |
163
|
|
|
* |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
public function getSlug() |
167
|
|
|
{ |
168
|
|
|
return $this->slug; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Set slug |
173
|
|
|
* |
174
|
|
|
* @param string $slug |
175
|
|
|
* @return Role |
176
|
|
|
*/ |
177
|
|
|
public function setSlug($slug) |
178
|
|
|
{ |
179
|
|
|
$this->slug = $slug; |
180
|
|
|
|
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Get performance |
186
|
|
|
* |
187
|
|
|
* @return Performance |
188
|
|
|
*/ |
189
|
3 |
|
public function getPerformance() |
190
|
|
|
{ |
191
|
3 |
|
return $this->performance; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Set performance |
196
|
|
|
* |
197
|
|
|
* @param Performance $performance |
198
|
|
|
* @return Role |
199
|
|
|
*/ |
200
|
|
|
public function setPerformance(Performance $performance = null) |
201
|
|
|
{ |
202
|
|
|
$this->performance = $performance; |
203
|
|
|
|
204
|
|
|
return $this; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Get employee |
209
|
|
|
* |
210
|
|
|
* @return Employee |
211
|
|
|
*/ |
212
|
5 |
|
public function getEmployee() |
213
|
|
|
{ |
214
|
5 |
|
return $this->employee; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Set employee |
219
|
|
|
* |
220
|
|
|
* @param Employee $employee |
221
|
|
|
* @return Role |
222
|
|
|
*/ |
223
|
|
|
public function setEmployee(Employee $employee = null) |
224
|
|
|
{ |
225
|
|
|
$this->employee = $employee; |
226
|
|
|
|
227
|
|
|
return $this; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return string |
232
|
|
|
*/ |
233
|
4 |
|
public function __toString() |
234
|
|
|
{ |
235
|
4 |
|
return $this->getTitle(); |
236
|
|
|
} |
237
|
|
|
} |
238
|
|
|
|