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