]> Raphaël G. Git Repositories - airbundle/blob - Entity/Application.php
Add created field to findAllIndexed results
[airbundle] / Entity / Application.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys AirBundle 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\ORM\Event\PreUpdateEventArgs;
15
16 /**
17 * Application
18 */
19 class Application {
20 /**
21 * Primary key
22 */
23 private ?int $id = null;
24
25 /**
26 * Dance instance
27 */
28 private Dance $dance;
29
30 /**
31 * Score
32 */
33 private ?float $score = null;
34
35 /**
36 * Cancel datetime
37 */
38 private ?\DateTime $canceled = null;
39
40 /**
41 * Create datetime
42 */
43 private \DateTime $created;
44
45 /**
46 * Update datetime
47 */
48 private \DateTime $updated;
49
50 /**
51 * Session instance
52 */
53 private $session = null;
54
55 /**
56 * User instance
57 */
58 private $user = null;
59
60 /**
61 * Constructor
62 */
63 public function __construct() {
64 //Set defaults
65 $this->created = new \DateTime('now');
66 $this->updated = new \DateTime('now');
67 }
68
69 /**
70 * Get id
71 *
72 * @return integer
73 */
74 public function getId(): ?int {
75 return $this->id;
76 }
77
78 /**
79 * Set dance
80 *
81 * @param Dance $dance
82 *
83 * @return Application
84 */
85 public function setDance(Dance $dance): Application {
86 $this->dance = $dance;
87
88 return $this;
89 }
90
91 /**
92 * Get dance
93 *
94 * @return Dance
95 */
96 public function getDance(): Dance {
97 return $this->dance;
98 }
99
100 /**
101 * Set score
102 *
103 * @param float $score
104 *
105 * @return Application
106 */
107 public function setScore(?float $score): Application {
108 $this->score = $score;
109
110 return $this;
111 }
112
113 /**
114 * Get score
115 *
116 * @return float
117 */
118 public function getScore(): ?float {
119 return $this->score;
120 }
121
122 /**
123 * Set canceled
124 *
125 * @param \DateTime $canceled
126 *
127 * @return Application
128 */
129 public function setCanceled(?\DateTime $canceled): Application {
130 $this->canceled = $canceled;
131
132 return $this;
133 }
134
135 /**
136 * Get canceled
137 *
138 * @return \DateTime
139 */
140 public function getCanceled(): ?\DateTime {
141 return $this->canceled;
142 }
143
144 /**
145 * Set created
146 *
147 * @param \DateTime $created
148 *
149 * @return Application
150 */
151 public function setCreated(\DateTime $created): Application {
152 $this->created = $created;
153
154 return $this;
155 }
156
157 /**
158 * Get created
159 *
160 * @return \DateTime
161 */
162 public function getCreated(): \DateTime {
163 return $this->created;
164 }
165
166 /**
167 * Set updated
168 *
169 * @param \DateTime $updated
170 *
171 * @return Application
172 */
173 public function setUpdated(\DateTime $updated): Application {
174 $this->updated = $updated;
175
176 return $this;
177 }
178
179 /**
180 * Get updated
181 *
182 * @return \DateTime
183 */
184 public function getUpdated(): \DateTime {
185 return $this->updated;
186 }
187
188 /**
189 * Set session
190 *
191 * @param Session $session
192 *
193 * @return Application
194 */
195 public function setSession(Session $session): Application {
196 $this->session = $session;
197
198 return $this;
199 }
200
201 /**
202 * Get session
203 *
204 * @return Session
205 */
206 public function getSession(): Session {
207 return $this->session;
208 }
209
210 /**
211 * Set user
212 *
213 * @param User $user
214 *
215 * @return Application
216 */
217 public function setUser(User $user): Application {
218 $this->user = $user;
219
220 return $this;
221 }
222
223 /**
224 * Get user
225 *
226 * @return User
227 */
228 public function getUser(): User {
229 return $this->user;
230 }
231
232 /**
233 * {@inheritdoc}
234 */
235 public function preUpdate(PreUpdateEventArgs $eventArgs) {
236 //Check that we have an application instance
237 if (($application = $eventArgs->getObject()) instanceof Application) {
238 //Set updated value
239 $application->setUpdated(new \DateTime('now'));
240 }
241 }
242 }