114 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Entity;
 | 
						|
 | 
						|
use App\Entity\Helpers\TrackedTrait;
 | 
						|
use App\Repository\SnipRepository;
 | 
						|
use Doctrine\Common\Collections\ArrayCollection;
 | 
						|
use Doctrine\Common\Collections\Collection;
 | 
						|
use Doctrine\ORM\Mapping as ORM;
 | 
						|
 | 
						|
#[ORM\Entity(repositoryClass: SnipRepository::class)]
 | 
						|
class Snip
 | 
						|
{
 | 
						|
    use TrackedTrait;
 | 
						|
 | 
						|
    #[ORM\Id]
 | 
						|
    #[ORM\GeneratedValue]
 | 
						|
    #[ORM\Column]
 | 
						|
    private ?int $id = null;
 | 
						|
 | 
						|
    #[ORM\Column(length: 255)]
 | 
						|
    private ?string $name = null;
 | 
						|
 | 
						|
    #[ORM\Column]
 | 
						|
    private ?bool $public = null;
 | 
						|
 | 
						|
    #[ORM\OneToMany(mappedBy: 'snip', targetEntity: SnipContent::class, orphanRemoval: true)]
 | 
						|
    private Collection $snipContents;
 | 
						|
 | 
						|
    #[ORM\Column(length: 255, nullable: true)]
 | 
						|
    private ?string $activeCommit = null;
 | 
						|
 | 
						|
    public function __construct()
 | 
						|
    {
 | 
						|
        $this->snipContents = new ArrayCollection();
 | 
						|
    }
 | 
						|
 | 
						|
    public function __toString(): string
 | 
						|
    {
 | 
						|
        return $this->name ?? '';
 | 
						|
    }
 | 
						|
 | 
						|
    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;
 | 
						|
    }
 | 
						|
 | 
						|
    public function addSnipContent(SnipContent $snipContent): self
 | 
						|
    {
 | 
						|
        if (!$this->snipContents->contains($snipContent)) {
 | 
						|
            $this->snipContents->add($snipContent);
 | 
						|
            $snipContent->setSnip($this);
 | 
						|
        }
 | 
						|
 | 
						|
        return $this;
 | 
						|
    }
 | 
						|
 | 
						|
    public function removeSnipContent(SnipContent $snipContent): self
 | 
						|
    {
 | 
						|
        if ($this->snipContents->removeElement($snipContent)) {
 | 
						|
            // set the owning side to null (unless already changed)
 | 
						|
            if ($snipContent->getSnip() === $this) {
 | 
						|
                $snipContent->setSnip(null);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        return $this;
 | 
						|
    }
 | 
						|
 | 
						|
    public function getActiveCommit(): ?string
 | 
						|
    {
 | 
						|
        return $this->activeCommit;
 | 
						|
    }
 | 
						|
 | 
						|
    public function setActiveCommit(?string $activeCommit): static
 | 
						|
    {
 | 
						|
        $this->activeCommit = $activeCommit;
 | 
						|
 | 
						|
        return $this;
 | 
						|
    }
 | 
						|
}
 |