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

Commit

Permalink
Merge pull request #191 from symfony-cmf/cleanup-parent
Browse files Browse the repository at this point in the history
removing parent from all but the full phpcr MenuNode document
  • Loading branch information
lsmith77 committed May 14, 2014
2 parents 19e5274 + ecb9e98 commit 9ab067f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

1.1.1
-----

* **2014-05-14**: [BC BREAK when extending Model] Removed parent from
MenuNodeBase classes as they are not required by knp menu.

1.1.0
-----

Expand Down
35 changes: 33 additions & 2 deletions Doctrine/Phpcr/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
namespace Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr;

use Doctrine\ODM\PHPCR\HierarchyInterface;
use Symfony\Cmf\Bundle\MenuBundle\Model\Menu as BaseMenu;
use Symfony\Cmf\Bundle\MenuBundle\Model\Menu as ModelMenu;
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode as ModelMenuNode;

class Menu extends BaseMenu implements HierarchyInterface
class Menu extends ModelMenu implements HierarchyInterface
{
/**
* Set the parent of this menu node
Expand All @@ -37,4 +38,34 @@ public function getParentDocument()
{
return $this->getParentObject();
}

/**
* Convenience method to set parent and name at the same time.
*
* @param $parent MenuNode
* @param $name string
*
* @return MenuNode - this instance
*/
public function setPosition($parent, $name)
{
$this->setParentObject($parent);
$this->setName($name);

return $this;
}

/**
* Add a child menu node, automatically setting the parent node.
*
* @param ModelMenuNode $child
*
* @return MenuNode - The newly added child node.
*/
public function addChild(ModelMenuNode $child)
{
$child->setParentObject($this);

return parent::addChild($child);
}
}
34 changes: 32 additions & 2 deletions Doctrine/Phpcr/MenuNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
namespace Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr;

use Doctrine\ODM\PHPCR\HierarchyInterface;
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode as BaseMenuNode;
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode as ModelMenuNode;

class MenuNode extends BaseMenuNode implements HierarchyInterface
class MenuNode extends ModelMenuNode implements HierarchyInterface
{
/**
* Set the parent of this menu node
Expand All @@ -37,4 +37,34 @@ public function getParentDocument()
{
return $this->getParentObject();
}

/**
* Convenience method to set parent and name at the same time.
*
* @param $parent MenuNode
* @param $name string
*
* @return MenuNode - this instance
*/
public function setPosition($parent, $name)
{
$this->setParentObject($parent);
$this->setName($name);

return $this;
}

/**
* Add a child menu node, automatically setting the parent node.
*
* @param MenuNode $child
*
* @return MenuNode - The newly added child node.
*/
public function addChild(ModelMenuNode $child)
{
$child->setParentObject($this);

return parent::addChild($child);
}
}
4 changes: 2 additions & 2 deletions Doctrine/Phpcr/MenuNodeBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr;

use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeBase as BaseMenuNodeBase;
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeBase as ModelMenuNodeBase;

class MenuNodeBase extends BaseMenuNodeBase
class MenuNodeBase extends ModelMenuNodeBase
{
}
19 changes: 1 addition & 18 deletions Model/MenuNodeBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,6 @@ public function setName($name)
return $this;
}

/**
* Convenience method to set parent and name at the same time.
*
* @param $parent MenuNode
* @param $name string
*
* @return MenuNode - this instance
*/
public function setPosition($parent, $name)
{
$this->parent = $parent;
$this->name = $name;

return $this;
}

/**
* Return the label assigned to this menu node
*
Expand Down Expand Up @@ -380,15 +364,14 @@ public function getChildren()
}

/**
* Add a child menu node, automatically setting the parent node.
* Add a child menu node under this node.
*
* @param MenuNode $child
*
* @return MenuNode - The newly added child node.
*/
public function addChild(MenuNode $child)
{
$child->setParentDocument($this);
$this->children[] = $child;

return $child;
Expand Down

0 comments on commit 9ab067f

Please sign in to comment.