<?php


namespace AutoAdmin\Bundle\Menu\Entity;


use AutoAdmin\Bundle\Content\Entity\AbstractUntranslated;
use AutoAdmin\Bundle\Content\Entity\Interfaces\MenuInterface;
use AutoAdmin\Bundle\Content\Entity\Traits\NameTrait;
use AutoAdmin\Bundle\Content\Entity\Traits\SlugTrait;
use AutoAdmin\Bundle\Content\Model\NameInterface;
use AutoAdmin\Bundle\Content\Model\SlugInterface;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Table(name: 'menu')]
#[ORM\Entity(repositoryClass: 'AutoAdmin\Bundle\Menu\Repository\MenuRepository')]
#[ORM\Cache(region: 'aa_menu')]
class Menu extends AbstractUntranslated implements NameInterface, SlugInterface, MenuInterface
{
    use NameTrait;
    use SlugTrait;

    #[ORM\OneToOne(mappedBy: 'menu', targetEntity: 'MenuItem', cascade: ['ALL'], orphanRemoval: true)]
    protected ?MenuItem $root = null;

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName($name): void
    {
        $this->name = $name;
    }

    public function getSlug(): string
    {
        return $this->slug;
    }

    public function setSlug(string $slug)
    {
        $this->slug = $slug;
    }

    public function getRoot(): ?MenuItem
    {
        return $this->root;
    }

    public function setRoot(?MenuItem $root): void
    {
        $this->root = $root;
    }
}
