Change snip and tag entities to public columns

This commit is contained in:
Tim
2025-07-24 14:51:55 +02:00
parent 8226ac24d8
commit 074c1d8570
15 changed files with 70 additions and 225 deletions

View File

@@ -10,47 +10,23 @@ trait TrackedTrait
{
#[ORM\Column]
#[ORM\JoinColumn(nullable: false)]
private ?DateTime $createdAt = null;
public ?DateTime $createdAt = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?User $createdBy = null;
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getCreatedAt(): ?DateTime
{
return $this->createdAt;
}
public function setCreatedAt(DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public ?User $createdBy = null;
public function setCreatedAtNowNoSeconds(): self
{
$this->setCreatedAt(DateTime::createFromFormat('Y-m-d H:i', date('Y-m-d H:i')));
$this->createdAt = DateTime::createFromFormat('Y-m-d H:i', date('Y-m-d H:i'));
return $this;
}
public function setCreatedAtNow(): self
{
$this->setCreatedAt(new DateTime());
$this->createdAt = new DateTime();
return $this;
}
}
}

View File

@@ -17,34 +17,34 @@ class Snip
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
public ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
public ?string $name = null;
#[ORM\Column]
private bool $public = false;
public bool $public = false;
#[ORM\OneToMany(mappedBy: 'snip', targetEntity: SnipContent::class, orphanRemoval: true)]
private Collection $snipContents;
public Collection $snipContents;
#[ORM\OneToOne]
private ?SnipContent $activeVersion = null;
public ?SnipContent $activeVersion = null;
#[ORM\Column(length: 255)]
private ?string $parser = null;
public ?string $parser = null;
#[ORM\Column]
private bool $visible = true;
public bool $visible = true;
#[ORM\Column]
private bool $archived = false;
public bool $archived = false;
/**
* @var Collection<int, Tag>
*/
#[ORM\ManyToMany(targetEntity: Tag::class, mappedBy: 'snips')]
private Collection $tags;
public Collection $tags;
public function __construct()
{
@@ -59,44 +59,7 @@ class Snip
public function getActiveText(): string
{
return SnipContentService::rebuildText($this->getActiveVersion());
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function isPublic(): ?bool
{
return $this->public;
}
public function setPublic(bool $public): self
{
$this->public = $public;
return $this;
}
/**
* @return Collection<int, SnipContent>
*/
public function getSnipContents(): Collection
{
return $this->snipContents;
return SnipContentService::rebuildText($this->activeVersion);
}
public function addSnipContent(SnipContent $snipContent): self
@@ -126,62 +89,6 @@ class Snip
return $this->snipContents->last() ?: null;
}
public function getActiveVersion(): ?SnipContent
{
return $this->activeVersion;
}
public function setActiveVersion(?SnipContent $activeVersion): static
{
$this->activeVersion = $activeVersion;
return $this;
}
public function getParser(): ?string
{
return $this->parser;
}
public function setParser(string $parser): static
{
$this->parser = $parser;
return $this;
}
public function isVisible(): ?bool
{
return $this->visible;
}
public function setVisible(bool $visible): static
{
$this->visible = $visible;
return $this;
}
public function isArchived(): ?bool
{
return $this->archived;
}
public function setArchived(bool $archived): static
{
$this->archived = $archived;
return $this;
}
/**
* @return Collection<int, Tag>
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tag $tag): static
{
if (!$this->tags->contains($tag)) {

View File

@@ -16,22 +16,22 @@ class Tag
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
public ?int $id = null;
#[ORM\Column(length: 255)]
#[Assert\NotEqualTo(SnipFilterRequest::TAG_ALL)]
#[Assert\NotEqualTo(SnipFilterRequest::TAG_NONE)]
private ?string $name = null;
public ?string $name = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
public ?User $user = null;
/**
* @var Collection<int, Snip>
*/
#[ORM\ManyToMany(targetEntity: Snip::class, inversedBy: 'tags')]
private Collection $snips;
public Collection $snips;
public function __construct()
{
@@ -43,43 +43,6 @@ class Tag
return $this->name ?? '';
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, Snip>
*/
public function getSnips(): Collection
{
return $this->snips;
}
public function addSnip(Snip $snip): static
{
if (!$this->snips->contains($snip)) {