vendor/roothirsch/core-bundle/Menu/Entity/MenuItem.php line 33

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\CoreBundle\Menu\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Roothirsch\CoreBundle\Menu\API\UpdateSorting;
  5. use Roothirsch\CoreBundle\Menu\Repository\MenuItemRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. /**
  11. *
  12. * @ORM\Entity(repositoryClass=MenuItemRepository::class)
  13. * @ORM\Table(name="menu_item")
  14. * @Gedmo\Tree(type="nested")
  15. * @ApiResource(
  16. * shortName="Menu/MenuItem",
  17. * itemOperations={
  18. * "get",
  19. * "put",
  20. * "delete",
  21. * "update_sorting"={
  22. * "method"="PUT",
  23. * "path"="/menu/menu_items/{id}/update-sorting",
  24. * "controller"=UpdateSorting::class
  25. * },
  26. * }
  27. * )
  28. */
  29. class MenuItem
  30. {
  31. /**
  32. * @ORM\Id
  33. * @ORM\GeneratedValue
  34. * @ORM\Column(type="integer")
  35. */
  36. private $id;
  37. /**
  38. * @ORM\Column(type="string", length=255, nullable=true)
  39. * @Gedmo\Translatable
  40. */
  41. private $title;
  42. /**
  43. * @ORM\Column(type="string", length=255)
  44. */
  45. private $type;
  46. /**
  47. * @ORM\Column(type="string", length=1024, nullable=true)
  48. */
  49. private $icon;
  50. /**
  51. * @ORM\Column(type="string", length=1024, nullable=true)
  52. */
  53. private $cssClass;
  54. /**
  55. * @ORM\Column(type="string", length=1024, nullable=true)
  56. */
  57. private $entityFqcn;
  58. /**
  59. * @ORM\Column(type="string", length=1024, nullable=true)
  60. */
  61. private $controllerFqcn;
  62. /**
  63. * @ORM\Column(type="string", length=1024, nullable=true)
  64. */
  65. private $entityId;
  66. /**
  67. * @ORM\Column(type="string", length=1024, nullable=true)
  68. */
  69. private $routeName;
  70. /**
  71. * @ORM\Column(type="string", length=1024, nullable=true)
  72. */
  73. private $controllerAction;
  74. /**
  75. * @ORM\Column(type="string", length=255, nullable=true)
  76. * @Gedmo\Translatable
  77. */
  78. private $url;
  79. /**
  80. * @Gedmo\TreeLeft
  81. * @ORM\Column(name="lft", type="integer")
  82. */
  83. private $lft;
  84. /**
  85. * @Gedmo\TreeLevel
  86. * @ORM\Column(name="lvl", type="integer")
  87. */
  88. private $lvl;
  89. /**
  90. * @Gedmo\TreeRight
  91. * @ORM\Column(name="rgt", type="integer")
  92. */
  93. private $rgt;
  94. /**
  95. * @Gedmo\TreeRoot
  96. * @ORM\ManyToOne(targetEntity="MenuItem")
  97. * @ORM\JoinColumn(name="tree_root", referencedColumnName="id", onDelete="CASCADE")
  98. */
  99. private $root;
  100. /**
  101. * @Gedmo\TreeParent
  102. * @ORM\ManyToOne(targetEntity="MenuItem", inversedBy="children")
  103. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
  104. */
  105. private $parent;
  106. /**
  107. * @ORM\OneToMany(targetEntity="MenuItem", mappedBy="parent_id")
  108. * @ORM\OrderBy({"lft" = "ASC"})
  109. */
  110. private $children;
  111. private ?array $config;
  112. public function __construct()
  113. {
  114. $this->children = new ArrayCollection();
  115. }
  116. public function __toString()
  117. {
  118. return strval($this->title);
  119. }
  120. public function getId(): ?int
  121. {
  122. return $this->id;
  123. }
  124. /**
  125. * @param mixed $id
  126. */
  127. public function setId($id): void
  128. {
  129. $this->id = $id;
  130. }
  131. public function getTitle(): ?string
  132. {
  133. return $this->title;
  134. }
  135. public function setTitle(string $title): self
  136. {
  137. $this->title = $title;
  138. return $this;
  139. }
  140. public function getType(): ?string
  141. {
  142. return $this->type;
  143. }
  144. public function setType(string $type): self
  145. {
  146. $this->type = $type;
  147. return $this;
  148. }
  149. public function setConfig(?array $config): self
  150. {
  151. $this->config = $config;
  152. return $this;
  153. }
  154. public function getIcon(): ?string
  155. {
  156. return $this->icon;
  157. }
  158. public function setIcon(?string $icon): self
  159. {
  160. $this->icon = $icon;
  161. return $this;
  162. }
  163. public function getEntityFqcn(): ?string
  164. {
  165. return $this->entityFqcn;
  166. }
  167. public function setEntityFqcn(?string $entityFqcn): self
  168. {
  169. $this->entityFqcn = $entityFqcn;
  170. return $this;
  171. }
  172. public function getRouteName(): ?string
  173. {
  174. return $this->routeName;
  175. }
  176. public function setRouteName($routeName): self
  177. {
  178. $this->routeName = $routeName;
  179. return $this;
  180. }
  181. public function getUrl(): ?string
  182. {
  183. return $this->url;
  184. }
  185. public function setUrl(?string $url): self
  186. {
  187. $this->url = $url;
  188. return $this;
  189. }
  190. public function getRoot()
  191. {
  192. return $this->root;
  193. }
  194. public function setParent($parent = null)
  195. {
  196. $this->parent = $parent;
  197. }
  198. public function getParent()
  199. {
  200. return $this->parent;
  201. }
  202. /**
  203. * Get the value of entityId
  204. */
  205. public function getEntityId()
  206. {
  207. return $this->entityId;
  208. }
  209. /**
  210. * Set the value of entityId
  211. *
  212. * @return self
  213. */
  214. public function setEntityId($entityId)
  215. {
  216. $this->entityId = $entityId;
  217. return $this;
  218. }
  219. /**
  220. * @return mixed
  221. */
  222. public function getCssClass()
  223. {
  224. return strval($this->cssClass);
  225. }
  226. /**
  227. * @param mixed $cssClass
  228. */
  229. public function setCssClass($cssClass): void
  230. {
  231. $this->cssClass = $cssClass;
  232. }
  233. /**
  234. * @return mixed
  235. */
  236. public function getControllerFqcn()
  237. {
  238. return $this->controllerFqcn;
  239. }
  240. /**
  241. * @param mixed $controllerFqcn
  242. */
  243. public function setControllerFqcn($controllerFqcn): void
  244. {
  245. $this->controllerFqcn = $controllerFqcn;
  246. }
  247. /**
  248. * @return mixed
  249. */
  250. public function getControllerAction()
  251. {
  252. return $this->controllerAction;
  253. }
  254. /**
  255. * @param mixed $controllerAction
  256. */
  257. public function setControllerAction($controllerAction): void
  258. {
  259. $this->controllerAction = $controllerAction;
  260. }
  261. }