94 lines
1.8 KiB
PHP
94 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* Menu.
|
|
*
|
|
* @ORM\Table(name="menu")
|
|
* @ORM\Entity(repositoryClass="App\Repository\MenuRepository")
|
|
*/
|
|
class Menu
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="string")
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Menuchild", mappedBy="menu", cascade={"persist"}, orphanRemoval=true)
|
|
* @ORM\OrderBy({"roworder" = "ASC"})
|
|
*/
|
|
private $menuchilds;
|
|
|
|
public function setId(int $id): self
|
|
{
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
$this->menuchilds = 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;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Menuchild>
|
|
*/
|
|
public function getMenuchilds(): Collection
|
|
{
|
|
return $this->menuchilds;
|
|
}
|
|
|
|
public function addMenuchild(Menuchild $menuchild): self
|
|
{
|
|
if (!$this->menuchilds->contains($menuchild)) {
|
|
$this->menuchilds->add($menuchild);
|
|
$menuchild->setMenu($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeMenuchild(Menuchild $menuchild): self
|
|
{
|
|
if ($this->menuchilds->removeElement($menuchild)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($menuchild->getMenu() === $this) {
|
|
$menuchild->setMenu(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|