1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys AirBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Entity
;
14 use Doctrine\Common\Collections\Collection
;
15 use Doctrine\Common\Collections\ArrayCollection
;
16 use Doctrine\ORM\Event\PreUpdateEventArgs
;
21 class GoogleCalendar
{
40 private \DateTime
$synchronized;
45 private \DateTime
$created;
50 private \DateTime
$updated;
53 * @var \Rapsys\AirBundle\Entity\GoogleToken
55 private GoogleToken
$googleToken;
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
65 public function __construct(GoogleToken
$googleToken, string $mail, string $summary, \DateTime
$synchronized = new \
DateTime('now')) {
67 $this->googleToken
= $googleToken;
69 $this->summary
= $summary;
70 $this->synchronized
= $synchronized;
71 $this->created
= new \
DateTime('now');
72 $this->updated
= new \
DateTime('now');
80 public function getId(): ?int {
88 * @return GoogleCalendar
90 public function setMail(string $mail): GoogleCalendar
{
101 public function getMail(): string {
108 * @param string $summary
109 * @return GoogleCalendar
111 public function setSummary(string $summary): GoogleCalendar
{
112 $this->summary
= $summary;
122 public function getSummary(): string {
123 return $this->summary
;
129 * @param \DateTime $synchronized
131 * @return GoogleCalendar
133 public function setSynchronized(\DateTime
$synchronized): GoogleCalendar
{
134 $this->synchronized
= $synchronized;
144 public function getSynchronized(): \DateTime
{
145 return $this->synchronized
;
151 * @param \DateTime $created
153 * @return GoogleCalendar
155 public function setCreated(\DateTime
$created): GoogleCalendar
{
156 $this->created
= $created;
166 public function getCreated(): \DateTime
{
167 return $this->created
;
173 * @param \DateTime $updated
175 * @return GoogleCalendar
177 public function setUpdated(\DateTime
$updated): GoogleCalendar
{
178 $this->updated
= $updated;
188 public function getUpdated(): \DateTime
{
189 return $this->updated
;
195 * @param \Rapsys\AirBundle\Entity\GoogleToken $googleToken
197 * @return GoogleCalendar
199 public function setGoogleToken(GoogleToken
$googleToken): GoogleCalendar
{
200 $this->googleToken
= $googleToken;
208 * @return \Rapsys\AirBundle\Entity\GoogleToken
210 public function getGoogleToken(): GoogleToken
{
211 return $this->googleToken
;
217 public function preUpdate(PreUpdateEventArgs
$eventArgs): ?GoogleCalendar
{
218 //Check that we have an snippet instance
219 if (($entity = $eventArgs->getEntity()) instanceof GoogleCalendar
) {
221 return $entity->setUpdated(new \
DateTime('now'));