Start on property keeping track of git db content
This commit is contained in:
@ -7,6 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Uid\Ulid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SnipContentRepository::class)]
|
||||
class SnipContent
|
||||
@ -14,27 +15,27 @@ class SnipContent
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
private ?Ulid $id = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'snipContents')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Snip $snip = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'child')]
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
|
||||
private ?self $parent = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
|
||||
private Collection $child;
|
||||
private Collection $children;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $text = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->child = new ArrayCollection();
|
||||
$this->children = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
public function getId(): ?Ulid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
@ -66,15 +67,15 @@ class SnipContent
|
||||
/**
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public function getChild(): Collection
|
||||
public function getChildren(): Collection
|
||||
{
|
||||
return $this->child;
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function addChild(self $child): self
|
||||
{
|
||||
if (!$this->child->contains($child)) {
|
||||
$this->child->add($child);
|
||||
if (!$this->children->contains($child)) {
|
||||
$this->children->add($child);
|
||||
$child->setParent($this);
|
||||
}
|
||||
|
||||
@ -83,7 +84,7 @@ class SnipContent
|
||||
|
||||
public function removeChild(self $child): self
|
||||
{
|
||||
if ($this->child->removeElement($child)) {
|
||||
if ($this->children->removeElement($child)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($child->getParent() === $this) {
|
||||
$child->setParent(null);
|
||||
|
Reference in New Issue
Block a user