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