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
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @ORM\Table(name="venue_sector") |
20
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\VenueSectorRepository") |
21
|
|
|
* @UniqueEntity(fields={"venue", "slug"}) |
22
|
|
|
* @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\VenueSectorTranslation") |
23
|
|
|
* @ExclusionPolicy("all") |
24
|
|
|
*/ |
25
|
|
|
class VenueSector extends AbstractPersonalTranslatable implements TranslatableInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var integer |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(name="id", type="integer") |
31
|
|
|
* @ORM\Id |
32
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
33
|
|
|
* @Type("integer") |
34
|
|
|
* @Expose() |
35
|
|
|
*/ |
36
|
|
|
protected $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
|
|
|
protected $title; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var ArrayCollection|Translation[] |
50
|
|
|
* |
51
|
|
|
* @ORM\OneToMany( |
52
|
|
|
* targetEntity="AppBundle\Entity\Translations\VenueSectorTranslation", |
53
|
|
|
* mappedBy="object", |
54
|
|
|
* cascade={"persist", "remove"} |
55
|
|
|
* ) |
56
|
|
|
*/ |
57
|
|
|
protected $translations; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var Venue |
61
|
|
|
* |
62
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Venue", inversedBy="venueSectors") |
63
|
|
|
*/ |
64
|
|
|
protected $venue; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var Collection|Seat[] |
68
|
|
|
* |
69
|
|
|
* @ORM\OneToMany( |
70
|
|
|
* targetEntity="AppBundle\Entity\Seat", |
71
|
|
|
* mappedBy="venueSector", |
72
|
|
|
* cascade={"persist", "remove"} |
73
|
|
|
* ) |
74
|
|
|
*/ |
75
|
|
|
protected $seats; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @Gedmo\Slug(fields={"title"}) |
79
|
|
|
* @ORM\Column(name="slug", type="string", length=255) |
80
|
|
|
* @Type("string") |
81
|
|
|
* @Expose |
82
|
|
|
*/ |
83
|
|
|
private $slug; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* VenueSector constructor. |
87
|
|
|
*/ |
88
|
|
|
public function __construct() |
89
|
|
|
{ |
90
|
|
|
parent::__construct(); |
91
|
|
|
$this->seats = new ArrayCollection(); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return integer |
96
|
|
|
*/ |
97
|
6 |
|
public function getId() |
98
|
|
|
{ |
99
|
6 |
|
return $this->id; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return VenueSector |
104
|
|
|
*/ |
105
|
1 |
|
public function unsetTranslations() |
106
|
|
|
{ |
107
|
1 |
|
$this->translations = null; |
108
|
|
|
|
109
|
1 |
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
3 |
|
public function getTitle() |
116
|
|
|
{ |
117
|
3 |
|
return $this->title; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param string $title |
122
|
|
|
* @return VenueSector |
123
|
|
|
*/ |
124
|
|
|
public function setTitle($title) |
125
|
|
|
{ |
126
|
|
|
$this->title = $title; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return Venue |
133
|
|
|
*/ |
134
|
2 |
|
public function getVenue() |
135
|
|
|
{ |
136
|
2 |
|
return $this->venue; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param Seat $seat |
141
|
|
|
* @return VenueSector |
142
|
|
|
*/ |
143
|
|
|
public function addSeat(Seat $seat) |
144
|
|
|
{ |
145
|
|
|
$this->seats[] = $seat; |
146
|
|
|
|
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @param Seat $seat |
152
|
|
|
*/ |
153
|
|
|
public function removeSeat(Seat $seat) |
154
|
|
|
{ |
155
|
|
|
$this->seats->removeElement($seat); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return Collection |
160
|
|
|
*/ |
161
|
|
|
public function getSeat() |
162
|
|
|
{ |
163
|
|
|
return $this->seats; |
|
|
|
|
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Get slug |
168
|
|
|
* |
169
|
|
|
* @return string |
170
|
|
|
*/ |
171
|
|
|
public function getSlug() |
172
|
|
|
{ |
173
|
|
|
return $this->slug; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return string |
178
|
|
|
*/ |
179
|
2 |
|
public function __toString() |
180
|
|
|
{ |
181
|
2 |
|
return $this->getTitle().' '.$this->getVenue(); |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|