]> Raphaël G. Git Repositories - airbundle/blob - Entity/Dance.php
Update translations
[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 //Set defaults
56 $this->created = new \DateTime('now');
57 $this->updated = new \DateTime('now');
58
59 //Set collections
60 $this->applications = new ArrayCollection();
61 $this->users = new ArrayCollection();
62 }
63
64 /**
65 * Get id
66 *
67 * @return integer
68 */
69 public function getId(): int {
70 return $this->id;
71 }
72
73 /**
74 * Set title
75 *
76 * @param string $title
77 *
78 * @return Dance
79 */
80 public function setTitle(string $title): Dance {
81 $this->title = $title;
82
83 return $this;
84 }
85
86 /**
87 * Get title
88 *
89 * @return string
90 */
91 public function getTitle(): string {
92 return $this->title;
93 }
94
95 /**
96 * Set created
97 *
98 * @param \DateTime $created
99 *
100 * @return Dance
101 */
102 public function setCreated(\DateTime $created): Dance {
103 $this->created = $created;
104
105 return $this;
106 }
107
108 /**
109 * Get created
110 *
111 * @return \DateTime
112 */
113 public function getCreated(): \DateTime {
114 return $this->created;
115 }
116
117 /**
118 * Set updated
119 *
120 * @param \DateTime $updated
121 *
122 * @return Dance
123 */
124 public function setUpdated(\DateTime $updated): Dance {
125 $this->updated = $updated;
126
127 return $this;
128 }
129
130 /**
131 * Get updated
132 *
133 * @return \DateTime
134 */
135 public function getUpdated(): \DateTime {
136 return $this->updated;
137 }
138
139 /**
140 * Add application
141 *
142 * @param Application $application
143 *
144 * @return Dance
145 */
146 public function addApplication(Application $application): Dance {
147 $this->applications[] = $application;
148
149 return $this;
150 }
151
152 /**
153 * Remove application
154 *
155 * @param Application $application
156 *
157 * @return bool
158 */
159 public function removeApplication(Application $application): bool {
160 return $this->applications->removeElement($application);
161 }
162
163 /**
164 * Get applications
165 *
166 * @return ArrayCollection
167 */
168 public function getApplications(): ArrayCollection {
169 return $this->applications;
170 }
171
172 /**
173 * Add user
174 *
175 * @param User $user
176 *
177 * @return Dance
178 */
179 public function addUser(User $user): Dance {
180 $this->users[] = $user;
181
182 return $this;
183 }
184
185 /**
186 * Remove user
187 *
188 * @param User $user
189 *
190 * @return bool
191 */
192 public function removeUser(User $user): bool {
193 return $this->users->removeElement($user);
194 }
195
196 /**
197 * Get users
198 *
199 * @return ArrayCollection
200 */
201 public function getUsers(): ArrayCollection {
202 return $this->users;
203 }
204
205 /**
206 * {@inheritdoc}
207 */
208 public function preUpdate(PreUpdateEventArgs $eventArgs) {
209 //Check that we have a dance instance
210 if (($dance = $eventArgs->getEntity()) instanceof Dance) {
211 //Set updated value
212 $dance->setUpdated(new \DateTime('now'));
213 }
214 }
215
216 /**
217 * Returns a string representation of the slot
218 *
219 * @return string
220 */
221 public function __toString(): string {
222 return $this->title;
223 }
224 }