src/Entity/LinkType.php line 17
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Repository\LinkTypeRepository;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Link;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
#[ApiResource]
#[ORM\Entity(repositoryClass: LinkTypeRepository::class)]
class LinkType implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $title;
#[ORM\Column(type: 'string', length: 255)]
private $originEntity;
#[ORM\OneToMany(targetEntity: Link::class, mappedBy: 'linkType', orphanRemoval: true, cascade: ['persist', 'remove'])]
private \Doctrine\Common\Collections\Collection|array $links;
public function __construct()
{
$this->links = new ArrayCollection();
}
public function __toString(): string
{
return (string) $this->title;
}
public function getId(): ?int
{
return $this->id;
}
/**
* Get the value of title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set the value of title
*
* @return self
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get the value of originEntity
*/
public function getOriginEntity()
{
return $this->originEntity;
}
/**
* Set the value of originEntity
*
* @return self
*/
public function setOriginEntity($originEntity)
{
$this->originEntity = $originEntity;
return $this;
}
/**
* @return Collection<int, Link>
*/
public function getLinks(): Collection
{
return $this->links;
}
public function addLink(Link $link): self
{
if (!$this->links->contains($link)) {
$this->links[] = $link;
$link->setLinkType($this);
}
return $this;
}
public function removeLink(Link $link): self
{
if ($this->links->removeElement($link)) {
// set the owning side to null (unless already changed)
if ($link->getLinkType() === $this) {
$link->setLinkType(null);
}
}
return $this;
}
}