1 | <?php |
||
16 | class Item implements ItemInterface |
||
17 | { |
||
18 | const URI_TYPE_ANCHOR = 'anchor'; |
||
19 | const URI_TYPE_EXTERNAL = 'external'; |
||
20 | const URI_TYPE_INTERNAL = 'internal'; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | * |
||
25 | * @ORM\Column(name="item_id", type="integer", nullable=false) |
||
26 | * @ORM\Id |
||
27 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
28 | */ |
||
29 | protected $id; |
||
30 | |||
31 | /** |
||
32 | * @Gedmo\SortableGroup |
||
33 | * |
||
34 | * @ORM\ManyToOne(targetEntity="Alpixel\Bundle\MenuBundle\Entity\Item", inversedBy="children") |
||
35 | * @ORM\JoinColumn(name="parent_id", referencedColumnName="item_id", onDelete="SET NULL") |
||
36 | */ |
||
37 | protected $parent; |
||
38 | |||
39 | /** |
||
40 | * @ORM\OneToMany(targetEntity="Alpixel\Bundle\MenuBundle\Entity\Item", mappedBy="parent") |
||
41 | * @ORM\OrderBy({"position": "ASC"}) |
||
42 | */ |
||
43 | protected $children; |
||
44 | |||
45 | /** |
||
46 | * @Gedmo\SortableGroup |
||
47 | * |
||
48 | * @ORM\ManyToOne(targetEntity="Alpixel\Bundle\MenuBundle\Entity\Menu", inversedBy="items") |
||
49 | * @ORM\JoinColumn(name="menu_id", referencedColumnName="menu_id") |
||
50 | */ |
||
51 | protected $menu; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | * |
||
56 | * @ORM\Column(name="name", type="string", length=255, nullable=false) |
||
57 | */ |
||
58 | protected $name; |
||
59 | |||
60 | /** |
||
61 | * @RouteExists |
||
62 | * @ORM\Column(name="uri", type="text", nullable=false) |
||
63 | */ |
||
64 | protected $uri; |
||
65 | |||
66 | /** |
||
67 | * @Gedmo\SortablePosition |
||
68 | * |
||
69 | * @ORM\Column(name="position", type="integer", nullable=false) |
||
70 | */ |
||
71 | protected $position; |
||
72 | |||
73 | /** |
||
74 | * @Gedmo\Slug(fields={"name"}, updatable=true, separator="_") |
||
75 | * @ORM\Column(length=128) |
||
76 | **/ |
||
77 | protected $slug; |
||
78 | |||
79 | public function __construct() |
||
83 | |||
84 | /** |
||
85 | * Get string defined. |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | public function __toString() |
||
93 | |||
94 | /** |
||
95 | * Get Id. |
||
96 | * |
||
97 | * @return int |
||
98 | */ |
||
99 | public function getId() |
||
103 | |||
104 | /** |
||
105 | * Get menu. |
||
106 | * |
||
107 | * @return Menu |
||
108 | */ |
||
109 | public function getMenu() |
||
113 | |||
114 | /** |
||
115 | * Set menu. |
||
116 | * |
||
117 | * @param Menu $menu |
||
118 | * |
||
119 | * @return self |
||
120 | */ |
||
121 | public function setMenu(MenuInterface $menu) |
||
127 | |||
128 | /** |
||
129 | * Get parent Item. |
||
130 | * |
||
131 | * @return null\Item |
||
132 | */ |
||
133 | public function getParent() |
||
137 | |||
138 | /** |
||
139 | * Set parent Item. |
||
140 | * |
||
141 | * @param ItemInterface $menu |
||
142 | * |
||
143 | * @return self |
||
144 | */ |
||
145 | public function setParent(ItemInterface $item = null) |
||
151 | |||
152 | /** |
||
153 | * Get children of Item. |
||
154 | * |
||
155 | * @return ArrayCollection (Item) |
||
156 | */ |
||
157 | public function getChildren() |
||
163 | |||
164 | /** |
||
165 | * Set Item from ArrayCollection. |
||
166 | * |
||
167 | * @param null\ArrayCollection |
||
168 | * |
||
169 | * @return self |
||
170 | */ |
||
171 | public function addChildren(ArrayCollection $collection) |
||
179 | |||
180 | /** |
||
181 | * Set children of Item. |
||
182 | * |
||
183 | * @param Item $item |
||
184 | * |
||
185 | * @return self |
||
186 | */ |
||
187 | public function setChildren(ItemInterface $item) |
||
195 | |||
196 | /** |
||
197 | * Remove children. |
||
198 | * |
||
199 | * @param ItemInterface $item |
||
200 | * |
||
201 | * @return $this |
||
202 | */ |
||
203 | public function removeChildren(ItemInterface $item) |
||
211 | |||
212 | /** |
||
213 | * Get name displayed in Item. |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | public function getName() |
||
221 | |||
222 | /** |
||
223 | * Set name displayed in Item. |
||
224 | * |
||
225 | * @param string |
||
226 | * |
||
227 | * @return self |
||
228 | */ |
||
229 | public function setName($name) |
||
235 | |||
236 | /** |
||
237 | * Get URL. |
||
238 | * |
||
239 | * @return string |
||
240 | */ |
||
241 | public function getUri() |
||
245 | |||
246 | /** |
||
247 | * Set URL. |
||
248 | * |
||
249 | * @param string $url |
||
250 | * |
||
251 | * @return self |
||
252 | */ |
||
253 | public function setUri($uri) |
||
259 | |||
260 | /** |
||
261 | * Get position of Item. |
||
262 | * |
||
263 | * @return int |
||
264 | */ |
||
265 | public function getPosition() |
||
269 | |||
270 | /** |
||
271 | * Set position. |
||
272 | * |
||
273 | * @param int $position |
||
274 | * |
||
275 | * @return self |
||
276 | */ |
||
277 | public function setPosition($position) |
||
283 | |||
284 | /** |
||
285 | * Gets the value of slug. |
||
286 | * |
||
287 | * @return mixed |
||
288 | */ |
||
289 | public function getSlug() |
||
293 | |||
294 | /** |
||
295 | * Sets the value of slug. |
||
296 | * |
||
297 | * @param mixed $slug the slug |
||
298 | * |
||
299 | * @return self |
||
300 | */ |
||
301 | public function setSlug($slug) |
||
307 | |||
308 | public static function getUriType() |
||
316 | |||
317 | public static function uriTypeExists($type) |
||
321 | } |
||
322 |