aboutsummaryrefslogtreecommitdiff
path: root/src/model/EventDTO.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-06-23 03:33:38 +0200
committerpolo <ordipolo@gmx.fr>2025-06-23 03:33:38 +0200
commitcebc19ef236aac2968d2ffccfcff9b975b63fa8d (patch)
tree5b8e08045a45063475f533bfae4b4524720fe7bd /src/model/EventDTO.php
parent8cf5ac1abf9e2a6134cb82d4582aecaa99b1331a (diff)
downloadcms-cebc19ef236aac2968d2ffccfcff9b975b63fa8d.zip
fullcalendar
Diffstat (limited to 'src/model/EventDTO.php')
-rw-r--r--src/model/EventDTO.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/model/EventDTO.php b/src/model/EventDTO.php
new file mode 100644
index 0000000..8d33733
--- /dev/null
+++ b/src/model/EventDTO.php
@@ -0,0 +1,49 @@
1<?php
2// src/model/EventDTO.php
3//
4// classe de données JSONifiable compatible avec fullcalendar
5// servira aussi pour l'import/export de fichiers .ics
6
7use App\Entity\Event;
8
9class EventDTO
10{
11 public int $id;
12 public string $title;
13 public string $start;
14 public string $end;
15 public bool $allDay;
16 public ?string $color;
17 public string $description;
18
19 public function __construct(Event $event)
20 {
21 $this->id = $event->getId();
22 $this->title = $event->getTitle();
23 $this->description = $event->getDescription() ?? ''; // renvoie $event->getDescription() si existe et ne vaut pas "null"
24 $this->allDay = $event->isAllDay();
25 $this->color = $event->getColor();
26
27 if($this->allDay){
28 $this->start = $event->getStart()->format('Y-m-d');
29 $this->end = $event->getEnd()->format('Y-m-d');
30 }
31 else{
32 $this->start = $event->getStart()->format('Y-m-d\TH:i:s\Z');
33 $this->end = $event->getEnd()->format('Y-m-d\TH:i:s\Z');
34 }
35 }
36
37 public function toArray(): array
38 {
39 return [
40 'id' => $this->id,
41 'title' => $this->title,
42 'description' => $this->description,
43 'start' => $this->start,
44 'end' => $this->end,
45 'allDay' => $this->allDay,
46 'color' => $this->color,
47 ];
48 }
49}