This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +74
-24
lines changed Expand file tree Collapse file tree 5 files changed +74
-24
lines changed Original file line number Diff line number Diff line change 11Changelog
22=========
33
4+ 1.1.1
5+ -----
6+
7+ * ** 2014-05-14** : [ BC BREAK when extending Model] Removed parent from
8+ MenuNodeBase classes as they are not required by knp menu.
9+
4101.1.0
511-----
612
Original file line number Diff line number Diff line change 1212namespace Symfony \Cmf \Bundle \MenuBundle \Doctrine \Phpcr ;
1313
1414use Doctrine \ODM \PHPCR \HierarchyInterface ;
15- use Symfony \Cmf \Bundle \MenuBundle \Model \Menu as BaseMenu ;
15+ use Symfony \Cmf \Bundle \MenuBundle \Model \Menu as ModelMenu ;
16+ use Symfony \Cmf \Bundle \MenuBundle \Model \MenuNode as ModelMenuNode ;
1617
17- class Menu extends BaseMenu implements HierarchyInterface
18+ class Menu extends ModelMenu implements HierarchyInterface
1819{
1920 /**
2021 * Set the parent of this menu node
@@ -37,4 +38,34 @@ public function getParentDocument()
3738 {
3839 return $ this ->getParentObject ();
3940 }
41+
42+ /**
43+ * Convenience method to set parent and name at the same time.
44+ *
45+ * @param $parent MenuNode
46+ * @param $name string
47+ *
48+ * @return MenuNode - this instance
49+ */
50+ public function setPosition ($ parent , $ name )
51+ {
52+ $ this ->setParentObject ($ parent );
53+ $ this ->setName ($ name );
54+
55+ return $ this ;
56+ }
57+
58+ /**
59+ * Add a child menu node, automatically setting the parent node.
60+ *
61+ * @param ModelMenuNode $child
62+ *
63+ * @return MenuNode - The newly added child node.
64+ */
65+ public function addChild (ModelMenuNode $ child )
66+ {
67+ $ child ->setParentObject ($ this );
68+
69+ return parent ::addChild ($ child );
70+ }
4071}
Original file line number Diff line number Diff line change 1212namespace Symfony \Cmf \Bundle \MenuBundle \Doctrine \Phpcr ;
1313
1414use Doctrine \ODM \PHPCR \HierarchyInterface ;
15- use Symfony \Cmf \Bundle \MenuBundle \Model \MenuNode as BaseMenuNode ;
15+ use Symfony \Cmf \Bundle \MenuBundle \Model \MenuNode as ModelMenuNode ;
1616
17- class MenuNode extends BaseMenuNode implements HierarchyInterface
17+ class MenuNode extends ModelMenuNode implements HierarchyInterface
1818{
1919 /**
2020 * Set the parent of this menu node
@@ -37,4 +37,34 @@ public function getParentDocument()
3737 {
3838 return $ this ->getParentObject ();
3939 }
40+
41+ /**
42+ * Convenience method to set parent and name at the same time.
43+ *
44+ * @param $parent MenuNode
45+ * @param $name string
46+ *
47+ * @return MenuNode - this instance
48+ */
49+ public function setPosition ($ parent , $ name )
50+ {
51+ $ this ->setParentObject ($ parent );
52+ $ this ->setName ($ name );
53+
54+ return $ this ;
55+ }
56+
57+ /**
58+ * Add a child menu node, automatically setting the parent node.
59+ *
60+ * @param MenuNode $child
61+ *
62+ * @return MenuNode - The newly added child node.
63+ */
64+ public function addChild (ModelMenuNode $ child )
65+ {
66+ $ child ->setParentObject ($ this );
67+
68+ return parent ::addChild ($ child );
69+ }
4070}
Original file line number Diff line number Diff line change 1111
1212namespace Symfony \Cmf \Bundle \MenuBundle \Doctrine \Phpcr ;
1313
14- use Symfony \Cmf \Bundle \MenuBundle \Model \MenuNodeBase as BaseMenuNodeBase ;
14+ use Symfony \Cmf \Bundle \MenuBundle \Model \MenuNodeBase as ModelMenuNodeBase ;
1515
16- class MenuNodeBase extends BaseMenuNodeBase
16+ class MenuNodeBase extends ModelMenuNodeBase
1717{
1818}
Original file line number Diff line number Diff line change @@ -192,22 +192,6 @@ public function setName($name)
192192 return $ this ;
193193 }
194194
195- /**
196- * Convenience method to set parent and name at the same time.
197- *
198- * @param $parent MenuNode
199- * @param $name string
200- *
201- * @return MenuNode - this instance
202- */
203- public function setPosition ($ parent , $ name )
204- {
205- $ this ->parent = $ parent ;
206- $ this ->name = $ name ;
207-
208- return $ this ;
209- }
210-
211195 /**
212196 * Return the label assigned to this menu node
213197 *
@@ -380,15 +364,14 @@ public function getChildren()
380364 }
381365
382366 /**
383- * Add a child menu node, automatically setting the parent node.
367+ * Add a child menu node under this node.
384368 *
385369 * @param MenuNode $child
386370 *
387371 * @return MenuNode - The newly added child node.
388372 */
389373 public function addChild (MenuNode $ child )
390374 {
391- $ child ->setParentDocument ($ this );
392375 $ this ->children [] = $ child ;
393376
394377 return $ child ;
You can’t perform that action at this time.
0 commit comments