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