From cebc19ef236aac2968d2ffccfcff9b975b63fa8d Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 23 Jun 2025 03:33:38 +0200 Subject: fullcalendar --- src/model/entities/Event.php | 125 +++++++++++++++++++++++++++++++++++++++++++ src/model/entities/Node.php | 2 +- 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 src/model/entities/Event.php (limited to 'src/model/entities') diff --git a/src/model/entities/Event.php b/src/model/entities/Event.php new file mode 100644 index 0000000..c85832f --- /dev/null +++ b/src/model/entities/Event.php @@ -0,0 +1,125 @@ + 255) + + #[ORM\Column(type: 'text')] + private string $description = ''; + // chatgpt: Dans un contexte API/Front comme FullCalendar, + // préférer une chaîne vide à une varaible "null" peut être plus pratique, + // car ça évite des contrôles côté JS. + + #[ORM\Column(type: 'datetime')] // chatgpt: Doctrine suppose UTC si pas de configuration spécifique + private \DateTimeInterface $start; // typage possible avec une interface, + //chatgpt: choix \DateTime par défaut, autorise \DateTimeImmutable + + #[ORM\Column(type: 'datetime')] + private \DateTimeInterface $end; + + #[ORM\Column(type: 'boolean')] + private bool $all_day; + + #[ORM\Column(type: 'string', length: 7, nullable: true)] + private ?string $color = null; + + public function __construct(string $title, string|\DateTimeInterface $start, string|\DateTimeInterface $end, bool $all_day, string $description = '', string $color = null){ + $this->title = $title; + $this->description = $description; + $this->start = gettype($start) === 'string' ? new \DateTime($start) : $start; + $this->end = gettype($end) === 'string' ? new \DateTime($end) : $end; + $this->all_day = $all_day; + $this->color = $color; + } + + public function updateFromJSON(array $json): void + { + $this->title = $json['title']; + $this->description = $json['description']; + $this->start = new \DateTime($json['start']); + $this->end = new \DateTime($json['end']); + $this->all_day = $json['allDay']; + $this->color = $json['color']; + } + + public function getId(): int + { + return $this->id; + } + + public function getTitle(): string + { + return $this->title; + } + /*public function setTitle(string $title): self + { + $this->title = $title; + return $this; + }*/ + + public function getDescription(): string + { + return $this->description; + } + /*public function setDescription(string $description = ''): self + { + $this->description = $description; + return $this; + }*/ + + public function getStart(): \DateTimeInterface + { + return $this->start; + } + /*public function setStart(\DateTimeInterface $start): self + { + $this->start = $start; + return $this; + }*/ + + public function getEnd(): \DateTimeInterface + { + return $this->end; + } + /*public function setEnd(\DateTimeInterface $end): self + { + $this->end = $end; + return $this; + }*/ + + public function isAllDay(): bool + { + return $this->all_day; + } + /*public function setAllDay(bool $all_day): self + { + $this->all_day = $all_day; + return $this; + }*/ + + public function getColor(): ?string + { + return $this->color; + } + /*public function setColor(?string $color): self + { + $this->color = $color; + return $this; + }*/ +} diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index 850f37d..711eb3e 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php @@ -56,7 +56,7 @@ class Node private array $children = []; // tableau de Node private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" - static private array $default_attributes = ['css_array' => ['body', 'head', 'nav', 'foot'],'js_array' => ['main']]; + static private array $default_attributes = ['css_array' => ['body', 'head', 'nav', 'foot', 'calendar'],'js_array' => ['main']]; public function __construct(string $name = '', ?string $article_timestamp = null, array $attributes = [], int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) { -- cgit v1.2.3