src/Entity/Collections.php line 26
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\GetCollection;use App\Repository\CollectionsRepository;use App\Trait\ActivableTrait;use App\Trait\DateTrait;use App\Trait\DeletableTrait;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: CollectionsRepository::class)]#[ApiResource(operations: [new GetCollection(normalizationContext: ['groups' => ['collections:list']])])]class Collections{use DateTrait;use ActivableTrait;use DeletableTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['collections:list', 'article:view'])]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups(['collections:list', 'article:view'])]private ?string $name = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $content = null;#[ORM\ManyToOne(cascade: ["persist"])]private ?Attachment $thumbnail = null;#[ORM\ManyToMany(targetEntity: Article::class, mappedBy: 'collections')]private Collection $articles;#[ORM\ManyToOne(inversedBy: 'collections')]#[ORM\JoinColumn(nullable: false)]private ?Establishment $establishment = null;#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'collections')]private ?self $parent = null;#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]private Collection $collections;#[ORM\Column(length: 50, nullable: true)]private ?string $icon = null;public function __construct(){$this->isActive = 0;if (is_null($this->createdAt)) $this->createdAt = new DateTimeImmutable();$this->updatedAt = new DateTimeImmutable();$this->articles = new ArrayCollection();$this->collections = new ArrayCollection();}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 getContent(): ?string{return $this->content;}public function setContent(string $content): self{$this->content = $content;return $this;}public function getThumbnail(): ?Attachment{return $this->thumbnail;}public function setThumbnail(?Attachment $thumbnail): self{$this->thumbnail = $thumbnail;return $this;}/*** @return Collection<int, Article>*/public function getArticles(): Collection{return $this->articles;}public function addArticle(Article $article): self{if (!$this->articles->contains($article)) {$this->articles->add($article);$article->addCollection($this);}return $this;}public function removeArticle(Article $article): self{if ($this->articles->removeElement($article)) {$article->removeCollection($this);}return $this;}public function __toString(): string{return $this->name;}public function getEstablishment(): ?Establishment{return $this->establishment;}public function setEstablishment(?Establishment $establishment): self{$this->establishment = $establishment;return $this;}public function getParent(): ?self{return $this->parent;}public function setParent(?self $parent): self{$this->parent = $parent;return $this;}/*** @return Collection<int, self>*/public function getCollections(): Collection{return $this->collections;}public function addCollection(self $collection): self{if (!$this->collections->contains($collection)) {$this->collections->add($collection);$collection->setParent($this);}return $this;}public function removeCollection(self $collection): self{if ($this->collections->removeElement($collection)) {// set the owning side to null (unless already changed)if ($collection->getParent() === $this) {$collection->setParent(null);}}return $this;}public function getIcon(): ?string{return $this->icon;}public function setIcon(?string $icon): static{$this->icon = $icon;return $this;}}