aboutsummaryrefslogtreecommitdiff
path: root/src/Model/EventDTO.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-10-23 00:47:32 +0200
committerpolo <ordipolo@gmx.fr>2026-10-23 00:47:32 +0200
commitf27cca08ff786ceff1870147f6d6bad14d71117f (patch)
treed36597a72025313d6faf4ed228755fa267ebe2f6 /src/Model/EventDTO.php
parentc7309f900ef05bd5cb313110ec159b761af394ec (diff)
downloadcms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.gz
cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.bz2
cms-f27cca08ff786ceff1870147f6d6bad14d71117f.zip
dossiers avec majuscule, namespace pour toutes les classes, autoload psr-4, UserDataService::createZip déplacé dans Backup
Diffstat (limited to 'src/Model/EventDTO.php')
-rw-r--r--src/Model/EventDTO.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/Model/EventDTO.php b/src/Model/EventDTO.php
new file mode 100644
index 0000000..b65176c
--- /dev/null
+++ b/src/Model/EventDTO.php
@@ -0,0 +1,53 @@
1<?php
2// src/Model/EventDTO.php
3//
4// classe de données JSONifiable compatible avec fullcalendar
5// servira éventuellement pour l'import/export de fichiers .ics
6
7declare(strict_types=1);
8
9namespace App\Model;
10
11use App\Entity\Event;
12
13class EventDTO
14{
15 public int $id;
16 public string $title;
17 public string $start;
18 public string $end;
19 public bool $allDay;
20 public ?string $color;
21 public string $description;
22
23 public function __construct(Event $event)
24 {
25 $this->id = $event->getId();
26 $this->title = $event->getTitle();
27 $this->description = $event->getDescription() ?? ''; // renvoie $event->getDescription() si existe et ne vaut pas "null"
28 $this->allDay = $event->isAllDay();
29 $this->color = $event->getColor();
30
31 if($this->allDay){
32 $this->start = $event->getStart()->format('Y-m-d');
33 $this->end = $event->getEnd()->format('Y-m-d');
34 }
35 else{
36 $this->start = $event->getStart()->format('Y-m-d\TH:i:s\Z');
37 $this->end = $event->getEnd()->format('Y-m-d\TH:i:s\Z');
38 }
39 }
40
41 public function toArray(): array
42 {
43 return [
44 'id' => $this->id,
45 'title' => $this->title,
46 'description' => $this->description,
47 'start' => $this->start,
48 'end' => $this->end,
49 'allDay' => $this->allDay,
50 'color' => $this->color,
51 ];
52 }
53}