diff --git a/Admin/MenuAdmin.php b/Admin/MenuAdmin.php index a8d7ec49..a07c3a50 100644 --- a/Admin/MenuAdmin.php +++ b/Admin/MenuAdmin.php @@ -16,7 +16,6 @@ class MenuAdmin extends AbstractMenuNodeAdmin { - /** * {@inheritDoc} */ diff --git a/CHANGELOG.md b/CHANGELOG.md index be59e711..0c96ee08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +1.1.0-RC3 +--------- + +* **2014-04-30**: Moved parent handling from MenuNodeBase to MenuNode to conform + with the CMF rules of base models being the minimal model. HierarchyInterface + on PHPCR MenuNode. + 1.1.0-RC2 --------- @@ -14,8 +21,8 @@ Changelog skip building the menu item altogether. * **2014-03-24**: setParent() and getParent() are now deprecated. - Use setParentDocument() and getParentDocument() instead. - Moreover, you should now enable the ChildExtension from the CoreBundle. + Use setParentObject() and getParentObject() instead. + When using Sonata admin, you can enable the ChildExtension from the CoreBundle. * **2014-01-10**: The PhpcrMenuProvider now attempts to prefetch the whole menu node tree to reduce the number of requests to the PHPCR storage. You can diff --git a/Doctrine/Phpcr/Menu.php b/Doctrine/Phpcr/Menu.php index 98084cee..c180cec3 100644 --- a/Doctrine/Phpcr/Menu.php +++ b/Doctrine/Phpcr/Menu.php @@ -11,8 +11,30 @@ namespace Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr; +use Doctrine\ODM\PHPCR\HierarchyInterface; use Symfony\Cmf\Bundle\MenuBundle\Model\Menu as BaseMenu; -class Menu extends BaseMenu +class Menu extends BaseMenu implements HierarchyInterface { + /** + * Set the parent of this menu node + * + * @param $parent MenuNode - Parent node + * + * @return MenuNode - this instance + */ + public function setParentDocument($parent) + { + return $this->setParentObject($parent); + } + + /** + * Returns the parent of this menu node + * + * @return object + */ + public function getParentDocument() + { + return $this->getParentObject(); + } } diff --git a/Doctrine/Phpcr/MenuNode.php b/Doctrine/Phpcr/MenuNode.php index 27ba2d5c..6cd99ce5 100644 --- a/Doctrine/Phpcr/MenuNode.php +++ b/Doctrine/Phpcr/MenuNode.php @@ -11,8 +11,30 @@ namespace Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr; +use Doctrine\ODM\PHPCR\HierarchyInterface; use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode as BaseMenuNode; -class MenuNode extends BaseMenuNode +class MenuNode extends BaseMenuNode implements HierarchyInterface { + /** + * Set the parent of this menu node + * + * @param $parent MenuNode - Parent node + * + * @return MenuNode - this instance + */ + public function setParentDocument($parent) + { + return $this->setParentObject($parent); + } + + /** + * Returns the parent of this menu node + * + * @return object + */ + public function getParentDocument() + { + return $this->getParentObject(); + } } diff --git a/Model/MenuNode.php b/Model/MenuNode.php index 82e043d5..b0c3ee80 100644 --- a/Model/MenuNode.php +++ b/Model/MenuNode.php @@ -11,6 +11,7 @@ namespace Symfony\Cmf\Bundle\MenuBundle\Model; +use Symfony\Cmf\Bundle\CoreBundle\Model\ChildInterface; use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface; use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface; use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishableInterface; @@ -32,8 +33,16 @@ class MenuNode extends MenuNodeBase implements TranslatableInterface, PublishTimePeriodInterface, - PublishableInterface + PublishableInterface, + ChildInterface { + /** + * Parent menu node. + * + * @var mixed + */ + protected $parent; + /** * @var string */ @@ -67,6 +76,40 @@ class MenuNode extends MenuNodeBase implements */ protected $publishEndDate; + /** + * {@inheritDoc} + */ + public function setParentObject($parent) + { + $this->parent = $parent; + + return $this; + } + + /** + * {@inheritDoc} + */ + public function getParentObject() + { + return $this->parent; + } + + /** + * @deprecated use setParentObject instead. + */ + public function setParent($parent) + { + return $this->setParentObject($parent); + } + + /** + * @deprecated use getParentObject instead. + */ + public function getParent() + { + return $this->getParentObject(); + } + /** * @return string the loaded locale of this menu node */ diff --git a/Model/MenuNodeBase.php b/Model/MenuNodeBase.php index 45cb52f7..10956c9b 100644 --- a/Model/MenuNodeBase.php +++ b/Model/MenuNodeBase.php @@ -23,7 +23,7 @@ * @author Uwe Jäger * @author Daniel Leech */ -class MenuNodeBase implements NodeInterface, ChildInterface +class MenuNodeBase implements NodeInterface { /** * Id of this menu node. @@ -32,13 +32,6 @@ class MenuNodeBase implements NodeInterface, ChildInterface */ protected $id; - /** - * Parent node. - * - * @var mixed - */ - protected $parent; - /** * Node name. * @@ -154,7 +147,7 @@ public function __construct($name = null) } /** - * Return ID (PHPCR path) of this menu node + * Return ID of this menu node * * @return string */ @@ -164,9 +157,7 @@ public function getId() } /** - * Sets ID (PHPCR path) of this menu node - * - * The recommended way is to use setParent and setName rather than setId. + * Sets ID of this menu node. * * @param $id string * @@ -179,48 +170,6 @@ public function setId($id) return $this; } - /** - * @deprecated Use setParentDocument instead. - */ - public function setParent($parent) - { - $this->parent = $parent; - - return $this; - } - - /** - * @deprecated Use getParentDocument instead. - */ - public function getParent() - { - return $this->parent; - } - - /** - * Set the parent of this menu node - * - * @param $parent MenuNode - Parent node - * - * @return MenuNode - this instance - */ - public function setParentDocument($parent) - { - $this->parent = $parent; - - return $this; - } - - /** - * Returns the parent of this menu node - * - * @return object - */ - public function getParentDocument() - { - return $this->parent; - } - /** * {@inheritDoc} */ @@ -284,9 +233,9 @@ public function setLabel($label) } /** - * Return the URI + * Return the URI this menu node points to. * - * @return $uri string + * @return string URI */ public function getUri() { diff --git a/Resources/config/doctrine-model/MenuNode.phpcr.xml b/Resources/config/doctrine-model/MenuNode.phpcr.xml index 65cd4802..1bbc047b 100644 --- a/Resources/config/doctrine-model/MenuNode.phpcr.xml +++ b/Resources/config/doctrine-model/MenuNode.phpcr.xml @@ -9,6 +9,7 @@ name="Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode" translator="attribute" > + diff --git a/Resources/config/doctrine-model/MenuNodeBase.phpcr.xml b/Resources/config/doctrine-model/MenuNodeBase.phpcr.xml index 9a0fc6da..0a02d587 100644 --- a/Resources/config/doctrine-model/MenuNodeBase.phpcr.xml +++ b/Resources/config/doctrine-model/MenuNodeBase.phpcr.xml @@ -9,11 +9,8 @@ name="Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeBase" > - - - + - diff --git a/Tests/Resources/Document/Content.php b/Tests/Resources/Document/Content.php index b701ead6..54b65a52 100644 --- a/Tests/Resources/Document/Content.php +++ b/Tests/Resources/Document/Content.php @@ -24,7 +24,7 @@ /** * @PHPCR\Document(referenceable=true) */ -class Content implements MenuNodeReferrersInterface, RouteReferrersReadInterface, ChildInterface +class Content implements MenuNodeReferrersInterface, RouteReferrersReadInterface { /** * @PHPCR\Id(strategy="assigned") diff --git a/Tests/Resources/app/config/test-services.xml b/Tests/Resources/app/config/test-services.xml index ed0b2247..51fa5480 100644 --- a/Tests/Resources/app/config/test-services.xml +++ b/Tests/Resources/app/config/test-services.xml @@ -23,8 +23,8 @@ class="Symfony\Cmf\Bundle\MenuBundle\Voter\RequestParentContentIdentityVoter"> contentDocument Symfony\Cmf\Bundle\MenuBundle\Tests\Resources\Document\Post + -