Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit b3c014a

Browse files
committed
Merge pull request #193 from symfony-cmf/add-child-cleanup
cleanup addChild method
2 parents 3f6450b + e9f357f commit b3c014a

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
1.2.x
5+
-----
6+
7+
* **2014-05-21**: [BC BREAK when extending BaseMenuNode] addChild and
8+
removeChild now accepts every Knp\Menu\NodeInterface instead of only
9+
MenuNode.
10+
411
1.1.1
512
-----
613

Doctrine/Phpcr/Menu.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr;
1313

1414
use Doctrine\ODM\PHPCR\HierarchyInterface;
15+
use Knp\Menu\NodeInterface;
1516
use Symfony\Cmf\Bundle\MenuBundle\Model\Menu as ModelMenu;
16-
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode as ModelMenuNode;
1717

1818
class Menu extends ModelMenu implements HierarchyInterface
1919
{
@@ -58,11 +58,11 @@ public function setPosition($parent, $name)
5858
/**
5959
* Add a child menu node, automatically setting the parent node.
6060
*
61-
* @param ModelMenuNode $child
61+
* @param NodeInterface $child
6262
*
63-
* @return ModelMenuNode - The newly added child node.
63+
* @return NodeInterface - The newly added child node.
6464
*/
65-
public function addChild(ModelMenuNode $child)
65+
public function addChild(NodeInterface $child)
6666
{
6767
if ($child instanceof MenuNode) {
6868
$child->setParentObject($this);

Doctrine/Phpcr/MenuNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr;
1313

1414
use Doctrine\ODM\PHPCR\HierarchyInterface;
15+
use Knp\Menu\NodeInterface;
1516
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode as ModelMenuNode;
1617

1718
class MenuNode extends ModelMenuNode implements HierarchyInterface
@@ -57,11 +58,11 @@ public function setPosition($parent, $name)
5758
/**
5859
* Add a child menu node, automatically setting the parent node.
5960
*
60-
* @param ModelMenuNode $child
61+
* @param NodeInterface $child
6162
*
62-
* @return ModelMenuNode - The newly added child node.
63+
* @return NodeInterface - The newly added child node.
6364
*/
64-
public function addChild(ModelMenuNode $child)
65+
public function addChild(NodeInterface $child)
6566
{
6667
if ($child instanceof MenuNode) {
6768
$child->setParentObject($this);

Model/MenuNodeBase.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,11 @@ public function getChildren()
365365
/**
366366
* Add a child menu node under this node.
367367
*
368-
* @param MenuNode $child
368+
* @param NodeInterface $child
369369
*
370-
* @return MenuNode The newly added child node.
370+
* @return NodeInterface The newly added child node.
371371
*/
372-
public function addChild(MenuNode $child)
372+
public function addChild(NodeInterface $child)
373373
{
374374
$this->children[] = $child;
375375

@@ -379,13 +379,15 @@ public function addChild(MenuNode $child)
379379
/**
380380
* Remove a child menu node
381381
*
382-
* @param MenuNode $child
382+
* @param NodeInterface $child
383383
*
384384
* @return MenuNodeBase $this
385385
*/
386-
public function removeChild(MenuNode $child)
386+
public function removeChild(NodeInterface $child)
387387
{
388388
$this->children->removeElement($child);
389+
390+
return $this;
389391
}
390392

391393
/**

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"target-dir": "Symfony/Cmf/Bundle/MenuBundle",
3939
"extra": {
4040
"branch-alias": {
41-
"dev-master": "1.1-dev"
41+
"dev-master": "1.2-dev"
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)