src/Entity/Menu.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Security\Permission;
  4. use App\Repository\MenuRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=MenuRepository::class)
  10.  */
  11. class Menu
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255, nullable=true)
  21.      */
  22.     private $route;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $label;
  27.     /**
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      */
  30.     private $icon;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=Menu::class, inversedBy="parent", fetch="EAGER")
  33.      */
  34.     private $menu;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity=Menu::class, mappedBy="menu")
  37.      */
  38.     private $parent;
  39.     /**
  40.      * @ORM\Column(type="boolean")
  41.      */
  42.     private $isActive false;
  43.     /**
  44.      * @ORM\Column(type="boolean")
  45.      */
  46.     private $isUri false;
  47.     /**
  48.      * @ORM\Column(type="boolean", nullable=true)
  49.      */
  50.     private $sogecAdmin false;
  51.     /**
  52.      * @ORM\Column(type="integer", options={"default": 1000})
  53.      */
  54.     private int $position 1000;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity=Permission::class, mappedBy="menu", orphanRemoval=true)
  57.      */
  58.     private $permissions;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=true)
  61.      */
  62.     private $permission_key;
  63.     public function __construct()
  64.     {
  65.         $this->parent = new ArrayCollection();
  66.         $this->permissions = new ArrayCollection();
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getRoute(): ?string
  73.     {
  74.         return $this->route;
  75.     }
  76.     public function setRoute(string $route): self
  77.     {
  78.         $this->route $route;
  79.         return $this;
  80.     }
  81.     public function getLabel(): ?string
  82.     {
  83.         return $this->label;
  84.     }
  85.     public function setLabel(string $label): self
  86.     {
  87.         $this->label $label;
  88.         return $this;
  89.     }
  90.     public function getIcon(): ?string
  91.     {
  92.         return $this->icon;
  93.     }
  94.     public function setIcon(?string $icon): self
  95.     {
  96.         $this->icon $icon;
  97.         return $this;
  98.     }
  99.     public function getMenu(): ?self
  100.     {
  101.         return $this->menu;
  102.     }
  103.     public function setMenu(?self $menu): self
  104.     {
  105.         $this->menu $menu;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection|self[]
  110.      */
  111.     public function getParent(): Collection
  112.     {
  113.         return $this->parent;
  114.     }
  115.     public function addParent(self $parent): self
  116.     {
  117.         if (!$this->parent->contains($parent)) {
  118.             $this->parent[] = $parent;
  119.             $parent->setMenu($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeParent(self $parent): self
  124.     {
  125.         if ($this->parent->removeElement($parent)) {
  126.             // set the owning side to null (unless already changed)
  127.             if ($parent->getMenu() === $this) {
  128.                 $parent->setMenu(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133.     public function getIsActive(): ?bool
  134.     {
  135.         return $this->isActive;
  136.     }
  137.     public function setIsActive(bool $isActive): self
  138.     {
  139.         $this->isActive $isActive;
  140.         return $this;
  141.     }
  142.     public function getIsUri(): ?bool
  143.     {
  144.         return $this->isUri;
  145.     }
  146.     public function setIsUri(bool $isUri): self
  147.     {
  148.         $this->isUri $isUri;
  149.         return $this;
  150.     }
  151.     public function isSogecAdmin(): bool
  152.     {
  153.         return $this->sogecAdmin;
  154.     }
  155.     public function setSogecAdmin(bool $sogecAdmin): self
  156.     {
  157.         $this->sogecAdmin $sogecAdmin;
  158.         return $this;
  159.     }
  160.     public function getPosition(): int
  161.     {
  162.         return $this->position;
  163.     }
  164.     public function setPosition(int $position): Menu
  165.     {
  166.         $this->position $position;
  167.         return $this;
  168.     }
  169.     public function __toString()
  170.     {
  171.         return $this->label;
  172.     }
  173.     /**
  174.      * @return Collection<int, Permission>
  175.      */
  176.     public function getPermissions(): Collection
  177.     {
  178.         return $this->permissions;
  179.     }
  180.     public function addPermission(Permission $permission): self
  181.     {
  182.         if (!$this->permissions->contains($permission)) {
  183.             $this->permissions[] = $permission;
  184.             $permission->setMenu($this);
  185.         }
  186.         return $this;
  187.     }
  188.     public function removePermission(Permission $permission): self
  189.     {
  190.         if ($this->permissions->removeElement($permission)) {
  191.             // set the owning side to null (unless already changed)
  192.             if ($permission->getMenu() === $this) {
  193.                 $permission->setMenu(null);
  194.             }
  195.         }
  196.         return $this;
  197.     }
  198.     public function getPermissionKey(): ?string
  199.     {
  200.         return $this->permission_key;
  201.     }
  202.     public function setPermissionKey(?string $permission_key): self
  203.     {
  204.         $this->permission_key $permission_key;
  205.         return $this;
  206.     }
  207. }