From 0f448fc7a1c0d29db3b9c32d112a7fe5906db6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Thu, 28 Nov 2024 18:18:35 +0100 Subject: [PATCH] Long form article entity definition --- src/Entity/Article.php | 320 +++++++++++++++++++++++++++++++++++ src/Enum/EventStatusEnum.php | 11 ++ src/Enum/IndexStatusEnum.php | 11 ++ src/Enum/KindsEnum.php | 22 +++ 4 files changed, 364 insertions(+) create mode 100644 src/Entity/Article.php create mode 100644 src/Enum/EventStatusEnum.php create mode 100644 src/Enum/IndexStatusEnum.php create mode 100644 src/Enum/KindsEnum.php diff --git a/src/Entity/Article.php b/src/Entity/Article.php new file mode 100644 index 0000000..d927696 --- /dev/null +++ b/src/Entity/Article.php @@ -0,0 +1,320 @@ +id; + } + + public function setId(int $id): static + { + $this->id = $id; + + return $this; + } + + public function getEventId(): ?string + { + return $this->eventId; + } + + public function setEventId(string $eventId): static + { + $this->eventId = $eventId; + + return $this; + } + + public function getSlug(): ?string + { + return $this->slug; + } + + public function setSlug(?string $slug): static + { + $this->slug = $slug; + + return $this; + } + + public function getContent(): ?string + { + return $this->content; + } + + public function setContent(?string $content): static + { + $this->content = $content; + + return $this; + } + + public function getKind(): ?KindsEnum + { + return $this->kind; + } + + public function setKind(?KindsEnum $kind): static + { + $this->kind = $kind; + + return $this; + } + + public function getTitle(): ?string + { + return $this->title; + } + + public function setTitle(?string $title): static + { + $this->title = $title; + + return $this; + } + + public function getSummary(): ?string + { + return $this->summary; + } + + public function setSummary(?string $summary): static + { + $this->summary = $summary; + + return $this; + } + + public function getPubkey(): ?string + { + return $this->pubkey; + } + + public function setPubkey(string $pubkey): static + { + $this->pubkey = $pubkey; + + return $this; + } + + public function getCreatedAt(): ?\DateTimeImmutable + { + return $this->createdAt; + } + + public function setCreatedAt(\DateTimeImmutable $createdAt): static + { + $this->createdAt = $createdAt; + + return $this; + } + + public function getSig(): ?string + { + return $this->sig; + } + + public function setSig(string $sig): static + { + $this->sig = $sig; + + return $this; + } + + public function getImage(): ?string + { + return $this->image; + } + + public function setImage(?string $image): static + { + $this->image = $image; + + return $this; + } + + public function getPublishedAt(): ?\DateTimeImmutable + { + return $this->publishedAt; + } + + public function setPublishedAt(\DateTimeImmutable $publishedAt): static + { + $this->publishedAt = $publishedAt; + + return $this; + } + + public function getTopics() + { + return $this->topics; + } + + public function setTopics($topics) + { + $this->topics = $topics; + + return $this; + } + + public function addTopic(string $topic): static + { + // remove # and lowercase topic + $topic = strtolower(str_replace('#', '', $topic)); + // check if topic already exists + if (in_array($topic, $this->topics ?? [])) { + return $this; + } + $this->topics[] = $topic; + + return $this; + } + + public function getEventStatus(): ?EventStatusEnum + { + return $this->eventStatus; + } + + public function setEventStatus(?EventStatusEnum $eventStatus): static + { + $this->eventStatus = $eventStatus; + + return $this; + } + + public function getIndexStatus(): ?IndexStatusEnum + { + return $this->indexStatus; + } + + public function setIndexStatus(?IndexStatusEnum $indexStatus): static + { + $this->indexStatus = $indexStatus; + + return $this; + } + + public function getCurrentPlaces(): ?array + { + return $this->currentPlaces; + } + + public function setCurrentPlaces(array $currentPlaces): static + { + $this->currentPlaces = $currentPlaces; + + return $this; + } + + public function getImgUrl(): ?string + { + return $this->imgUrl; + } + + public function setImgUrl(?string $imgUrl): static + { + $this->imgUrl = $imgUrl; + + return $this; + } + + public function getRatingNegative(): ?int + { + return $this->ratingNegative; + } + + public function setRatingNegative(?int $ratingNegative): static + { + $this->ratingNegative = $ratingNegative; + + return $this; + } + + public function getRatingPositive(): ?int + { + return $this->ratingPositive; + } + + public function setRatingPositive(?int $ratingPositive): static + { + $this->ratingPositive = $ratingPositive; + + return $this; + } + + public function isDraft() + { + return $this->eventStatus === EventStatusEnum::PREVIEW; + } +} diff --git a/src/Enum/EventStatusEnum.php b/src/Enum/EventStatusEnum.php new file mode 100644 index 0000000..1c81791 --- /dev/null +++ b/src/Enum/EventStatusEnum.php @@ -0,0 +1,11 @@ +