This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Tests/Functional/Doctrine/Phpcr Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 12
12
13
13
namespace Symfony \Cmf \Bundle \MenuBundle \Model ;
14
14
15
+ use Doctrine \Common \Collections \ArrayCollection ;
16
+ use Doctrine \Common \Collections \Collection ;
15
17
use Knp \Menu \NodeInterface ;
16
18
use Symfony \Cmf \Bundle \CoreBundle \Model \ChildInterface ;
17
19
@@ -48,9 +50,9 @@ class MenuNodeBase implements NodeInterface, ChildInterface
48
50
/**
49
51
* Child menu nodes
50
52
*
51
- * @var MenuNode[]
53
+ * @var Collection
52
54
*/
53
- protected $ children = array () ;
55
+ protected $ children ;
54
56
55
57
/**
56
58
* Menu label.
@@ -149,6 +151,7 @@ class MenuNodeBase implements NodeInterface, ChildInterface
149
151
public function __construct ($ name = null )
150
152
{
151
153
$ this ->name = $ name ;
154
+ $ this ->children = new ArrayCollection ();
152
155
}
153
156
154
157
/**
@@ -443,6 +446,16 @@ public function addChild(MenuNode $child)
443
446
return $ child ;
444
447
}
445
448
449
+ /**
450
+ * Remove a child menu node
451
+ *
452
+ * @param MenuNode $child
453
+ */
454
+ public function removeChild (MenuNode $ child )
455
+ {
456
+ $ this ->children ->removeElement ($ child );
457
+ }
458
+
446
459
/**
447
460
* Gets the route parameters.
448
461
*
Original file line number Diff line number Diff line change @@ -147,5 +147,14 @@ public function testMenuNode()
147
147
148
148
$ menuNode = $ this ->dm ->findTranslation (null , '/test/test-node ' , 'fr ' );
149
149
$ this ->assertEquals ('fr ' , $ menuNode ->getLocale ());
150
+
151
+ $ child = $ this ->dm ->find (null , '/test/test-node/child1 ' );
152
+ $ menuNode = $ child ->getParent ();
153
+ $ this ->assertCount (1 , $ menuNode ->getChildren ());
154
+ $ menuNode ->removeChild ($ child );
155
+ $ this ->dm ->flush ();
156
+ $ this ->dm ->clear ();
157
+ $ menuNode = $ this ->dm ->find (null , '/test/test-node ' );
158
+ $ this ->assertCount (0 , $ menuNode ->getChildren ());
150
159
}
151
160
}
You can’t perform that action at this time.
0 commit comments