1 | <?php |
||
15 | class Item implements ItemInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var integer |
||
19 | * |
||
20 | * @ORM\Column(name="item_id", type="integer", nullable=false) |
||
21 | * @ORM\Id |
||
22 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
23 | */ |
||
24 | protected $id; |
||
25 | |||
26 | /** |
||
27 | * @Gedmo\SortableGroup |
||
28 | * |
||
29 | * @ORM\ManyToOne(targetEntity="Alpixel\Bundle\MenuBundle\Entity\Item", inversedBy="children") |
||
30 | * @ORM\JoinColumn(name="parent_id", referencedColumnName="item_id") |
||
31 | */ |
||
32 | protected $parent; |
||
33 | |||
34 | /** |
||
35 | * @ORM\OneToMany(targetEntity="Alpixel\Bundle\MenuBundle\Entity\Item", mappedBy="parent") |
||
36 | */ |
||
37 | protected $children; |
||
38 | |||
39 | /** |
||
40 | * @ORM\ManyToOne(targetEntity="Alpixel\Bundle\MenuBundle\Entity\Menu", inversedBy="items") |
||
41 | * @ORM\JoinColumn(name="menu_id", referencedColumnName="menu_id") |
||
42 | */ |
||
43 | protected $menu; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | * |
||
48 | * @ORM\Column(name="name", type="string", length=255, nullable=false) |
||
49 | */ |
||
50 | protected $name; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | * |
||
55 | * @ORM\Column(name="uri", type="text", nullable=false) |
||
56 | */ |
||
57 | protected $uri; |
||
58 | |||
59 | /** |
||
60 | * @Gedmo\SortablePosition |
||
61 | * |
||
62 | * @ORM\Column(name="position", type="integer", nullable=false) |
||
63 | */ |
||
64 | protected $position; |
||
65 | |||
66 | public function __construct() |
||
70 | |||
71 | /** |
||
72 | * Get string defined |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function __toString() |
||
80 | |||
81 | /** |
||
82 | * Get Id |
||
83 | * |
||
84 | * @return integer |
||
85 | */ |
||
86 | public function getId() |
||
90 | |||
91 | /** |
||
92 | * Get menu |
||
93 | * |
||
94 | * @return Menu |
||
95 | */ |
||
96 | public function getMenu() |
||
100 | |||
101 | /** |
||
102 | * Set menu |
||
103 | * |
||
104 | * @param Menu $menu |
||
105 | * |
||
106 | * @return self |
||
107 | */ |
||
108 | public function setMenu(MenuInterface $menu) |
||
114 | |||
115 | /** |
||
116 | * Get parent Item |
||
117 | * |
||
118 | * @return null\Item |
||
119 | */ |
||
120 | public function getParent() |
||
124 | |||
125 | /** |
||
126 | * Set parent Item |
||
127 | * |
||
128 | * @param ItemInterface $menu |
||
129 | * |
||
130 | * @return self |
||
131 | */ |
||
132 | public function setParent(ItemInterface $item = null) |
||
138 | |||
139 | |||
140 | /** |
||
141 | * Get chidlren of Item |
||
142 | * |
||
143 | * @return null\ArrayCollection (Item) |
||
144 | */ |
||
145 | public function getChidlren() |
||
149 | |||
150 | /** |
||
151 | * Set Item from ArrayCollection |
||
152 | * |
||
153 | * @param null\ArrayCollection |
||
154 | * |
||
155 | * @return self |
||
156 | */ |
||
157 | public function addChildren(ArrayCollection $collection = null) |
||
167 | |||
168 | /** |
||
169 | * Set chidlren of Item |
||
170 | * |
||
171 | * @param Item $item |
||
172 | * |
||
173 | * @return self |
||
174 | */ |
||
175 | public function setChidlren(ItemInterface $item) |
||
181 | |||
182 | /** |
||
183 | * Get name displayed in Item |
||
184 | * |
||
185 | * @return string |
||
186 | */ |
||
187 | public function getName() |
||
191 | |||
192 | /** |
||
193 | * Set name displayed in Item |
||
194 | * |
||
195 | * @param string |
||
196 | * |
||
197 | * @return self |
||
198 | */ |
||
199 | public function setName($name) |
||
205 | |||
206 | /** |
||
207 | * Get URL |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | public function getUri() |
||
215 | |||
216 | /** |
||
217 | * Set URL |
||
218 | * |
||
219 | * @param string $url |
||
220 | * |
||
221 | * @return self |
||
222 | */ |
||
223 | public function setUri($uri) |
||
229 | |||
230 | /** |
||
231 | * Get position of Item |
||
232 | * |
||
233 | * @return integer |
||
234 | */ |
||
235 | public function getPosition() |
||
239 | |||
240 | |||
241 | /** |
||
242 | * Set position |
||
243 | * |
||
244 | * @param int $position |
||
245 | * |
||
246 | * @return self |
||
247 | */ |
||
248 | public function setPosition($position) |
||
254 | } |
||
255 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: