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

Commit ecb9e98

Browse files
committed
removing parent from all but the full phpcr MenuNode document
1 parent 19e5274 commit ecb9e98

File tree

5 files changed

+74
-24
lines changed

5 files changed

+74
-24
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
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+
410
1.1.0
511
-----
612

Doctrine/Phpcr/Menu.php

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

1414
use 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
}

Doctrine/Phpcr/MenuNode.php

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

1414
use 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
}

Doctrine/Phpcr/MenuNodeBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace 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
}

Model/MenuNodeBase.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)