<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="menu_items")
*/
class MenuItem
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $url;
/**
* @ORM\ManyToOne(targetEntity=Menu::class, inversedBy="menuItems")
*/
private $menu;
/**
* @ORM\Column(type="string", length=255)
*/
private $contentType; // 'External', 'Page', 'Brand', etc.
/**
* @ORM\ManyToMany(targetEntity=Marque::class)
* @ORM\JoinTable(name="menu_item_marques")
*/
private $marques;
/**
* @ORM\ManyToOne(targetEntity=MenuItem::class, inversedBy="children")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity=MenuItem::class, mappedBy="parent")
*/
private $children;
public function __construct()
{
$this->children = new ArrayCollection();
$this->marques = new ArrayCollection();
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection|self[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setParent($this);
}
return $this;
}
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
// set the owning side to null (unless already changed)
if ($child->getParent() === $this) {
$child->setParent(null);
}
}
return $this;
}
/**
* @return Collection|Marque[]
*/
public function getMarques(): Collection
{
return $this->marques;
}
public function addMarque(Marque $marque): self
{
if (!$this->marques->contains($marque)) {
$this->marques[] = $marque;
}
return $this;
}
public function removeMarque(Marque $marque): self
{
$this->marques->removeElement($marque);
return $this;
}
}