]> Raphaël G. Git Repositories - airbundle/blob - Entity/Dance.php
Rename locales
[airbundle] / Entity / Dance.php
1 <?php declare(strict_types=1);
2
3 /*
4 * this file is part of the rapsys packbundle package.
5 *
6 * (c) raphaël gertz <symfony@rapsys.eu>
7 *
8 * for the full copyright and license information, please view the license
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Entity;
13
14 use Doctrine\Common\Collections\ArrayCollection;
15 use Doctrine\ORM\Event\PreUpdateEventArgs;
16
17 /**
18 * Dance
19 */
20 class Dance {
21 /**
22 * @var integer
23 */
24 private $id;
25
26 /**
27 * @var string
28 */
29 protected $title;
30
31 /**
32 * @var \DateTime
33 */
34 private $created;
35
36 /**
37 * @var \DateTime
38 */
39 private $updated;
40
41 /**
42 * @var ArrayCollection
43 */
44 private $applications;
45
46 /**
47 * @var ArrayCollection
48 */
49 private $users;
50
51 /**
52 * Constructor
53 */
54 public function __construct() {
55 $this->applications = new ArrayCollection();
56 $this->users = new ArrayCollection();
57 }
58
59 /**
60 * Get id
61 *
62 * @return integer
63 */
64 public function getId(): int {
65 return $this->id;
66 }
67
68 /**
69 * Set title
70 *
71 * @param string $title
72 *
73 * @return Dance
74 */
75 public function setTitle(string $title): Dance {
76 $this->title = $title;
77
78 return $this;
79 }
80
81 /**
82 * Get title
83 *
84 * @return string
85 */
86 public function getTitle(): string {
87 return $this->title;
88 }
89
90 /**
91 * Set created
92 *
93 * @param \DateTime $created
94 *
95 * @return Dance
96 */
97 public function setCreated(\DateTime $created): Dance {
98 $this->created = $created;
99
100 return $this;
101 }
102
103 /**
104 * Get created
105 *
106 * @return \DateTime
107 */
108 public function getCreated(): \DateTime {
109 return $this->created;
110 }
111
112 /**
113 * Set updated
114 *
115 * @param \DateTime $updated
116 *
117 * @return Dance
118 */
119 public function setUpdated(\DateTime $updated): Dance {
120 $this->updated = $updated;
121
122 return $this;
123 }
124
125 /**
126 * Get updated
127 *
128 * @return \DateTime
129 */
130 public function getUpdated(): \DateTime {
131 return $this->updated;
132 }
133
134 /**
135 * Add application
136 *
137 * @param Application $application
138 *
139 * @return Dance
140 */
141 public function addApplication(Application $application): Dance {
142 $this->applications[] = $application;
143
144 return $this;
145 }
146
147 /**
148 * Remove application
149 *
150 * @param Application $application
151 *
152 * @return bool
153 */
154 public function removeApplication(Application $application): bool {
155 return $this->applications->removeElement($application);
156 }
157
158 /**
159 * Get applications
160 *
161 * @return ArrayCollection
162 */
163 public function getApplications(): ArrayCollection {
164 return $this->applications;
165 }
166
167 /**
168 * Add user
169 *
170 * @param User $user
171 *
172 * @return Dance
173 */
174 public function addUser(User $user): Dance {
175 $this->users[] = $user;
176
177 return $this;
178 }
179
180 /**
181 * Remove user
182 *
183 * @param User $user
184 *
185 * @return bool
186 */
187 public function removeUser(User $user): bool {
188 return $this->users->removeElement($user);
189 }
190
191 /**
192 * Get users
193 *
194 * @return ArrayCollection
195 */
196 public function getUsers(): ArrayCollection {
197 return $this->users;
198 }
199
200 /**
201 * {@inheritdoc}
202 */
203 public function preUpdate(PreUpdateEventArgs $eventArgs) {
204 //Check that we have an session instance
205 if (($dance = $eventArgs->getEntity()) instanceof Dance) {
206 //Set updated value
207 $dance->setUpdated(new \DateTime('now'));
208 }
209 }
210
211 /**
212 * Returns a string representation of the slot
213 *
214 * @return string
215 */
216 public function __toString(): string {
217 return $this->title;
218 }
219 }