<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Trait\TimestampableTrait;
use App\Repository\MenuRepository;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
#[ORM\Entity(repositoryClass: MenuRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Menu
{
use TimestampableTrait;
#[Assert\NotBlank]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $title;
#[ORM\OneToMany(mappedBy: 'menus', targetEntity: Sousmenu::class)]
private $sousmenus;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $path;
#[ORM\Column(type: 'text', nullable: true)]
private $content;
#[ORM\Column(type: 'json', nullable: true)]
private $image = [];
#[ORM\Column(type: 'json',nullable: true)]
private $video = [];
#[ORM\OneToMany(mappedBy: 'menu', targetEntity: Event::class)]
private $events;
#[ORM\OneToMany(mappedBy: 'menu', targetEntity: Agenda::class)]
private $agendas;
#[ORM\OneToMany(mappedBy: 'menu', targetEntity: Magazine::class)]
private $magazines;
#[ORM\Column(nullable: true)]
private ?bool $statut = null;
#[ORM\Column(nullable: true)]
private ?int $position = null;
public function __construct()
{
$this->sousmenus = new ArrayCollection();
$this->events = new ArrayCollection();
$this->agendas = new ArrayCollection();
$this->magazines = new ArrayCollection();
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection<int, Sousmenu>
*/
public function getSousmenus(): Collection
{
return $this->sousmenus;
}
public function addSousmenu(Sousmenu $sousmenu): self
{
if (!$this->sousmenus->contains($sousmenu)) {
$this->sousmenus[] = $sousmenu;
$sousmenu->setMenus($this);
}
return $this;
}
public function removeSousmenu(Sousmenu $sousmenu): self
{
if ($this->sousmenus->removeElement($sousmenu)) {
// set the owning side to null (unless already changed)
if ($sousmenu->getMenus() === $this) {
$sousmenu->setMenus(null);
}
}
return $this;
}
public function __toString()
{
return $this->title;
}
public function getPath(): ?string
{
return $this->path;
}
public function setPath(?string $path): self
{
$this->path = $path;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getImage(): array
{
return $this->image;
}
public function setImage(?array $image): self
{
$this->image = $image;
return $this;
}
public function getVideo(): array
{
return $this->video;
}
public function setVideo(?array $video): self
{
$this->video = $video;
return $this;
}
/**
* @return Collection<int, Event>
*/
public function getEvents(): Collection
{
return $this->events;
}
public function addEvent(Event $event): self
{
if (!$this->events->contains($event)) {
$this->events[] = $event;
$event->setMenu($this);
}
return $this;
}
public function removeEvent(Event $event): self
{
if ($this->events->removeElement($event)) {
// set the owning side to null (unless already changed)
if ($event->getMenu() === $this) {
$event->setMenu(null);
}
}
return $this;
}
/**
* @return Collection<int, Agenda>
*/
public function getAgendas(): Collection
{
return $this->agendas;
}
public function addAgenda(Agenda $agenda): self
{
if (!$this->agendas->contains($agenda)) {
$this->agendas[] = $agenda;
$agenda->setMenu($this);
}
return $this;
}
public function removeAgenda(Agenda $agenda): self
{
if ($this->agendas->removeElement($agenda)) {
// set the owning side to null (unless already changed)
if ($agenda->getMenu() === $this) {
$agenda->setMenu(null);
}
}
return $this;
}
/**
* @return Collection<int, Magazine>
*/
public function getMagazines(): Collection
{
return $this->magazines;
}
public function addMagazine(Magazine $magazine): self
{
if (!$this->magazines->contains($magazine)) {
$this->magazines[] = $magazine;
$magazine->setMenu($this);
}
return $this;
}
public function removeMagazine(Magazine $magazine): self
{
if ($this->magazines->removeElement($magazine)) {
// set the owning side to null (unless already changed)
if ($magazine->getMenu() === $this) {
$magazine->setMenu(null);
}
}
return $this;
}
public function isStatut(): ?bool
{
return $this->statut;
}
public function setStatut(?bool $statut): self
{
$this->statut = $statut;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
}