src/Entity/MenuTree.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. /**
  6. * @Gedmo\Tree(type="nested")
  7. * @ORM\Entity(repositoryClass="App\Repository\MenuTreeRepository")
  8. * @ORM\Table(name="app_menu")
  9. * NestedTreeRepository
  10. */
  11. class MenuTree
  12. {
  13. /**
  14. * @ORM\Id()
  15. * @ORM\GeneratedValue(strategy="IDENTITY")
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="string")
  21. */
  22. private $libelle;
  23. /**
  24. * @Gedmo\TreeLeft
  25. * @ORM\Column(type="integer")
  26. */
  27. private $lft;
  28. /**
  29. * @Gedmo\TreeRight
  30. * @ORM\Column(type="integer")
  31. */
  32. private $rgt;
  33. /**
  34. * @Gedmo\TreeParent
  35. * @ORM\ManyToOne(targetEntity="MenuTree", inversedBy="children")
  36. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
  37. */
  38. private $parent;
  39. /**
  40. * @Gedmo\TreeRoot
  41. * @ORM\Column(type="integer", nullable=true)
  42. */
  43. private $root;
  44. /**
  45. * @Gedmo\TreeLevel
  46. * @ORM\Column(name="lvl", type="integer")
  47. */
  48. private $level;
  49. /**
  50. * @ORM\OneToMany(targetEntity="MenuTree", mappedBy="parent")
  51. */
  52. private $children;
  53. /**
  54. * @ORM\Column(type="string", nullable=true)
  55. */
  56. private $icon;
  57. /**
  58. * @ORM\Column(type="string", nullable=true)
  59. */
  60. private $route;
  61. /**
  62. * @ORM\Column(type="string", nullable=true)
  63. */
  64. private $role;
  65. public function getId(): ?int
  66. {
  67. return $this->id;
  68. }
  69. public function getLibelle(): ?string
  70. {
  71. return $this->libelle;
  72. }
  73. public function setLibelle(string $libelle): self
  74. {
  75. $this->libelle = $libelle;
  76. return $this;
  77. }
  78. /**
  79. * @return mixed
  80. */
  81. public function getIcon()
  82. {
  83. return $this->icon;
  84. }
  85. /**
  86. * @param mixed $icon
  87. * @return MenuTree
  88. */
  89. public function setIcon($icon)
  90. {
  91. $this->icon = $icon;
  92. return $this;
  93. }
  94. /**
  95. * @return mixed
  96. */
  97. public function getLft()
  98. {
  99. return $this->lft;
  100. }
  101. /**
  102. * @param mixed $lft
  103. * @return MenuTree
  104. */
  105. public function setLft($lft)
  106. {
  107. $this->lft = $lft;
  108. return $this;
  109. }
  110. /**
  111. * @return mixed
  112. */
  113. public function getRgt()
  114. {
  115. return $this->rgt;
  116. }
  117. /**
  118. * @param mixed $rgt
  119. * @return MenuTree
  120. */
  121. public function setRgt($rgt)
  122. {
  123. $this->rgt = $rgt;
  124. return $this;
  125. }
  126. /**
  127. * @return mixed
  128. */
  129. public function getParent()
  130. {
  131. return $this->parent;
  132. }
  133. /**
  134. * @param mixed $parent
  135. * @return MenuTree
  136. */
  137. public function setParent($parent)
  138. {
  139. $this->parent = $parent;
  140. return $this;
  141. }
  142. /**
  143. * @return mixed
  144. */
  145. public function isRoot()
  146. {
  147. return (bool)$this->root;
  148. }
  149. /**
  150. * @param mixed $root
  151. * @return MenuTree
  152. */
  153. public function setRoot($root)
  154. {
  155. $this->root = $root;
  156. return $this;
  157. }
  158. /**
  159. * @return mixed
  160. */
  161. public function getLevel()
  162. {
  163. return $this->level;
  164. }
  165. /**
  166. * @param mixed $level
  167. * @return MenuTree
  168. */
  169. public function setLevel($level)
  170. {
  171. $this->level = $level;
  172. return $this;
  173. }
  174. /**
  175. * @return mixed
  176. */
  177. public function getChildren()
  178. {
  179. return $this->children;
  180. }
  181. /**
  182. * @param mixed $children
  183. * @return MenuTree
  184. */
  185. public function setChildren($children)
  186. {
  187. $this->children = $children;
  188. return $this;
  189. }
  190. /**
  191. * @return mixed
  192. */
  193. public function getRoute()
  194. {
  195. return $this->route;
  196. }
  197. /**
  198. * @param mixed $route
  199. * @return MenuTree
  200. */
  201. public function setRoute($route)
  202. {
  203. $this->route = $route;
  204. return $this;
  205. }
  206. /**
  207. * @return bool
  208. */
  209. public function isLeaf()
  210. {
  211. return $this->lft + 1 == $this->rgt;
  212. }
  213. /**
  214. * @return mixed
  215. */
  216. public function getRole()
  217. {
  218. return $this->role;
  219. }
  220. /**
  221. * @param mixed $role
  222. * @return MenuTree
  223. */
  224. public function setRole($role)
  225. {
  226. $this->role = $role;
  227. return $this;
  228. }
  229. }