Integrate snipContent more tightly into snip and cleanup old code

This commit is contained in:
Tim
2023-12-20 22:37:06 +01:00
parent 64bd7e3642
commit 5624fc3a74
9 changed files with 67 additions and 45 deletions

View File

@ -27,8 +27,8 @@ class Snip
#[ORM\OneToMany(mappedBy: 'snip', targetEntity: SnipContent::class, orphanRemoval: true)]
private Collection $snipContents;
#[ORM\Column(length: 255, nullable: true)]
private ?string $activeCommit = null;
#[ORM\ManyToOne]
private ?SnipContent $activeVersion = null;
public function __construct()
{
@ -99,14 +99,19 @@ class Snip
return $this;
}
public function getActiveCommit(): ?string
public function getLatestVersion(): ?SnipContent
{
return $this->activeCommit;
return $this->snipContents->last();
}
public function setActiveCommit(?string $activeCommit): static
public function getActiveVersion(): ?SnipContent
{
$this->activeCommit = $activeCommit;
return $this->activeVersion;
}
public function setActiveVersion(?SnipContent $activeVersion): static
{
$this->activeVersion = $activeVersion;
return $this;
}