From f27cca08ff786ceff1870147f6d6bad14d71117f Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 23 Oct 2026 00:47:32 +0200 Subject: =?UTF-8?q?dossiers=20avec=20majuscule,=20namespace=20pour=20toute?= =?UTF-8?q?s=20les=20classes,=20autoload=20psr-4,=20UserDataService::creat?= =?UTF-8?q?eZip=20d=C3=A9plac=C3=A9=20dans=20Backup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/Entity/Event.php | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 src/Model/Entity/Event.php (limited to 'src/Model/Entity/Event.php') diff --git a/src/Model/Entity/Event.php b/src/Model/Entity/Event.php new file mode 100644 index 0000000..3b81da7 --- /dev/null +++ b/src/Model/Entity/Event.php @@ -0,0 +1,129 @@ + 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(array $json){ + $this->securedUpdateFromJSON($json); + } + + public function securedUpdateFromJSON(array $json): void + { + $this->title = htmlspecialchars($json['title']); + $this->description = htmlspecialchars($json['description']); + try{ + $this->start = new \Datetime($json['start']); + $this->end = new \Datetime($json['end']); + } + catch(\Exception $e){ + throw new \InvalidArgumentException('Bad date input'); + } + $all_day = filter_var($json['allDay'] ?? null, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); + if(!is_bool($all_day)){ + throw new \InvalidArgumentException('Bad checkbox input'); + } + $this->all_day = $all_day; + $this->color = isset($json['color']) ? htmlspecialchars($json['color']) : null; + } + + 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; + }*/ +} -- cgit v1.2.3