4 changed files with 364 additions and 0 deletions
@ -0,0 +1,320 @@
@@ -0,0 +1,320 @@
|
||||
<?php |
||||
|
||||
namespace App\Entity; |
||||
|
||||
use App\Enum\EventStatusEnum; |
||||
use App\Enum\IndexStatusEnum; |
||||
use App\Enum\KindsEnum; |
||||
use App\Repository\NostrEventRepository; |
||||
use Doctrine\DBAL\Types\Types; |
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
#[ORM\Entity(repositoryClass: NostrEventRepository::class)] |
||||
class Article |
||||
{ |
||||
#[ORM\Id] |
||||
#[ORM\GeneratedValue] |
||||
#[ORM\Column(length: 225, nullable: true)] |
||||
private ?int $id = null; |
||||
|
||||
#[ORM\Column(length: 225, nullable: true)] |
||||
private ?string $eventId = null; |
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)] |
||||
private ?string $slug = null; |
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)] |
||||
private ?string $content = null; |
||||
|
||||
#[ORM\Column(nullable: true, enumType: KindsEnum::class)] |
||||
private ?KindsEnum $kind = null; |
||||
|
||||
#[ORM\Column(length: 225, nullable: true)] |
||||
private ?string $title = null; |
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)] |
||||
private ?string $summary = null; |
||||
|
||||
#[ORM\Column(length: 255)] |
||||
private ?string $pubkey = null; |
||||
|
||||
#[ORM\Column(nullable: true)] |
||||
private ?\DateTimeImmutable $createdAt = null; |
||||
|
||||
#[ORM\Column(length: 255)] |
||||
private ?string $sig = null; |
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)] |
||||
private ?string $image = null; |
||||
|
||||
#[ORM\Column(nullable: true)] |
||||
private ?\DateTimeImmutable $publishedAt = null; |
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true)] |
||||
private $topics = null; |
||||
|
||||
#[ORM\Column(nullable: true, enumType: EventStatusEnum::class)] |
||||
private ?EventStatusEnum $eventStatus = EventStatusEnum::PREVIEW; |
||||
|
||||
#[ORM\Column(nullable: true, enumType: IndexStatusEnum::class)] |
||||
private ?IndexStatusEnum $indexStatus = IndexStatusEnum::NOT_INDEXED; |
||||
|
||||
#[ORM\Column(length: 255, nullable: true)] |
||||
private ?string $imgUrl = null; |
||||
|
||||
// Local properties |
||||
#[ORM\Column(type: Types::JSON, nullable: true)] |
||||
private ?array $currentPlaces; |
||||
|
||||
#[ORM\Column(type: Types::INTEGER, nullable: true)] |
||||
private ?int $ratingNegative = null; |
||||
|
||||
#[ORM\Column(type: Types::INTEGER, nullable: true)] |
||||
private ?int $ratingPositive = null; |
||||
|
||||
public function getId(): ?int |
||||
{ |
||||
return $this->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; |
||||
} |
||||
} |
||||
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
<?php |
||||
|
||||
namespace App\Enum; |
||||
|
||||
enum EventStatusEnum: int |
||||
{ |
||||
case PREVIEW = 0; |
||||
case DRAFT = 1; |
||||
case PUBLISHED = 2; |
||||
case ARCHIVED = 3; // when newer edits exist, this is no longer the latest version |
||||
} |
||||
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
<?php |
||||
|
||||
namespace App\Enum; |
||||
|
||||
enum IndexStatusEnum: int |
||||
{ |
||||
case NOT_INDEXED = 0; |
||||
case TO_BE_INDEXED = 1; |
||||
case INDEXED = 2; |
||||
case DO_NOT_INDEX = 3; |
||||
} |
||||
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
<?php |
||||
|
||||
namespace App\Enum; |
||||
|
||||
enum KindsEnum: int |
||||
{ |
||||
case METADATA = 0; // metadata, NIP-01 |
||||
case TEXT_NOTE = 1; // text note, NIP-01 |
||||
case REPOST = 6; // Only wraps kind 1, NIP-18 |
||||
case GENERIC_REPOST = 16; // Generic repost, original kind signalled in a "k" tag, NIP-18 |
||||
case PINNED_LONGFORM = 10023; // Special purpose curation set, NIP-51, seems deprecated? |
||||
case HTTP_AUTH = 27235; // NIP-98, HTTP Auth |
||||
case CURATION_SET = 30004; // NIP-51 |
||||
case LONGFORM = 30023; // NIP-23 |
||||
case LONGFORM_DRAFT = 30024; // NIP-23 |
||||
case CONTENT_SEARCH = 5302; |
||||
case CONTENT_INDEX = 5312; |
||||
case CONTENT_SEARCH_RESULT = 6302; |
||||
case CONTENT_INDEX_RESULT = 6312; |
||||
case HIGHLIGHTS = 9802; |
||||
case APP_DATA = 30078; // NIP-78, Arbitrary custom app data |
||||
} |
||||
Loading…
Reference in new issue