blob: 70013dddec50e29e93c46c3ca56e1c91b900ee0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<?php
// src/model/EventDTO.php
//
// classe de données JSONifiable compatible avec fullcalendar
// servira aussi pour l'import/export de fichiers .ics
declare(strict_types=1);
use App\Entity\Event;
class EventDTO
{
public int $id;
public string $title;
public string $start;
public string $end;
public bool $allDay;
public ?string $color;
public string $description;
public function __construct(Event $event)
{
$this->id = $event->getId();
$this->title = $event->getTitle();
$this->description = $event->getDescription() ?? ''; // renvoie $event->getDescription() si existe et ne vaut pas "null"
$this->allDay = $event->isAllDay();
$this->color = $event->getColor();
if($this->allDay){
$this->start = $event->getStart()->format('Y-m-d');
$this->end = $event->getEnd()->format('Y-m-d');
}
else{
$this->start = $event->getStart()->format('Y-m-d\TH:i:s\Z');
$this->end = $event->getEnd()->format('Y-m-d\TH:i:s\Z');
}
}
public function toArray(): array
{
return [
'id' => $this->id,
'title' => $this->title,
'description' => $this->description,
'start' => $this->start,
'end' => $this->end,
'allDay' => $this->allDay,
'color' => $this->color,
];
}
}
|