1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\Common\Collections\Collection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
9
|
|
|
use Gedmo\Translatable\Document\Translation; |
10
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
11
|
|
|
use JMS\Serializer\Annotation\Expose; |
12
|
|
|
use JMS\Serializer\Annotation\Type; |
13
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface; |
14
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable; |
15
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @ORM\Table(name="venue_sector") |
19
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\VenueSectorRepository") |
20
|
|
|
* @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\VenueSectorTranslation") |
21
|
|
|
* @ExclusionPolicy("all") |
22
|
|
|
*/ |
23
|
|
View Code Duplication |
class VenueSector extends AbstractPersonalTranslatable implements TranslatableInterface |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var integer |
27
|
|
|
* |
28
|
|
|
* @ORM\Column(name="id", type="integer") |
29
|
|
|
* @ORM\Id |
30
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
31
|
|
|
*/ |
32
|
|
|
protected $id; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
* @Gedmo\Translatable |
37
|
|
|
* @Assert\NotBlank() |
38
|
|
|
* @ORM\Column(type="string", length=255) |
39
|
|
|
* @Type("string") |
40
|
|
|
* @Expose() |
41
|
|
|
*/ |
42
|
|
|
protected $title; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var ArrayCollection|Translation[] |
46
|
|
|
* |
47
|
|
|
* @ORM\OneToMany( |
48
|
|
|
* targetEntity="AppBundle\Entity\Translations\VenueSectorTranslation", |
49
|
|
|
* mappedBy="object", |
50
|
|
|
* cascade={"persist", "remove"} |
51
|
|
|
* ) |
52
|
|
|
*/ |
53
|
|
|
protected $translations; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var Venue |
57
|
|
|
* |
58
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Venue", inversedBy="venueSectors") |
59
|
|
|
* @Type("AppBundle\Entity\Venue") |
60
|
|
|
* @Expose() |
61
|
|
|
*/ |
62
|
|
|
protected $venue; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var Collection|Seat[] |
66
|
|
|
* |
67
|
|
|
* @ORM\OneToMany( |
68
|
|
|
* targetEntity="AppBundle\Entity\Seat", |
69
|
|
|
* mappedBy="venueSector", |
70
|
|
|
* cascade={"persist", "remove"} |
71
|
|
|
* ) |
72
|
|
|
*/ |
73
|
|
|
protected $seats; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @ORM\Column(name="slug", type="string", length=255) |
77
|
|
|
* @Type("string") |
78
|
|
|
* @Expose |
79
|
|
|
*/ |
80
|
|
|
private $slug; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* VenueSector constructor. |
84
|
|
|
*/ |
85
|
|
|
public function __construct() |
86
|
|
|
{ |
87
|
|
|
parent::__construct(); |
88
|
|
|
$this->seats = new ArrayCollection(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return integer |
93
|
|
|
*/ |
94
|
|
|
public function getId() |
95
|
|
|
{ |
96
|
|
|
return $this->id; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return VenueSector |
101
|
|
|
*/ |
102
|
|
|
public function unsetTranslations() |
103
|
|
|
{ |
104
|
|
|
$this->translations = null; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
public function getTitle() |
113
|
|
|
{ |
114
|
|
|
return $this->title; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param string $title |
119
|
|
|
* @return VenueSector |
120
|
|
|
*/ |
121
|
|
|
public function setTitle($title) |
122
|
|
|
{ |
123
|
|
|
$this->title = $title; |
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return Venue |
130
|
|
|
*/ |
131
|
|
|
public function getVenue() |
132
|
|
|
{ |
133
|
|
|
return $this->venue; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param Seat $seat |
138
|
|
|
* @return VenueSector |
139
|
|
|
*/ |
140
|
|
|
public function addSeat(Seat $seat) |
141
|
|
|
{ |
142
|
|
|
$this->seats[] = $seat; |
143
|
|
|
|
144
|
|
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param Seat $seat |
149
|
|
|
*/ |
150
|
|
|
public function removeSeat(Seat $seat) |
151
|
|
|
{ |
152
|
|
|
$this->seats->removeElement($seat); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return Collection |
157
|
|
|
*/ |
158
|
|
|
public function getSeat() |
159
|
|
|
{ |
160
|
|
|
return $this->seats; |
|
|
|
|
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Get slug |
165
|
|
|
* |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
|
|
public function getSlug() |
169
|
|
|
{ |
170
|
|
|
return $this->slug; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Set slug |
175
|
|
|
* |
176
|
|
|
* @param string $slug |
177
|
|
|
* @return VenueSector |
178
|
|
|
*/ |
179
|
|
|
public function setSlug($slug) |
180
|
|
|
{ |
181
|
|
|
$this->slug = $slug; |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return string |
188
|
|
|
*/ |
189
|
|
|
public function __toString() |
190
|
|
|
{ |
191
|
|
|
return $this->getTitle(); |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.