Skip to content

Commit 49636fe

Browse files
committed
Use child interface
1 parent cb9124e commit 49636fe

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

CHANGELOG.md

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

4+
* **2014-03-25**: setParent() and getParent() are now deprecated.
5+
Use setParentDocument() and getParentDocument() instead.
6+
Moreover, you should now enable the ChildExtension from the CoreBundle.
7+
48
* **2014-03-23**: When using PHPCR-ODM, routes can now be generated with their
59
uuid as route name as well, in addition to the repository path.
610

Doctrine/Phpcr/RedirectRoute.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr;
1414

15+
use Symfony\Cmf\Bundle\CoreBundle\Model\ChildInterface;
1516
use Symfony\Cmf\Bundle\RoutingBundle\Model\RedirectRoute as RedirectRouteModel;
1617
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
1718

@@ -21,7 +22,7 @@
2122
* This extends the RedirectRoute Model. We need to re-implement everything
2223
* that the PHPCR Route document adds.
2324
*/
24-
class RedirectRoute extends RedirectRouteModel implements PrefixInterface
25+
class RedirectRoute extends RedirectRouteModel implements PrefixInterface, ChildInterface
2526
{
2627
/**
2728
* parent document
@@ -75,21 +76,39 @@ public function __construct($addFormatPattern = false, $addTrailingSlash = false
7576
$this->addTrailingSlash = $addTrailingSlash;
7677
}
7778

79+
/**
80+
* @deprecated Use setParentDocument instead.
81+
*/
82+
public function setParent($parent)
83+
{
84+
$this->parent = $parent;
85+
86+
return $this;
87+
}
88+
89+
/**
90+
* @deprecated Use getParentDocument instead.
91+
*/
92+
public function getParent()
93+
{
94+
return $this->parent;
95+
}
96+
7897
/**
7998
* Move the route by setting a parent.
8099
*
81100
* Note that this will change the URL this route matches.
82101
*
83102
* @param object $parent the new parent document
84103
*/
85-
public function setParent($parent)
104+
public function setParentDocument($parent)
86105
{
87106
$this->parent = $parent;
88107

89108
return $this;
90109
}
91110

92-
public function getParent()
111+
public function getParentDocument()
93112
{
94113
return $this->parent;
95114
}

Doctrine/Phpcr/Route.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\Common\Collections\Collection;
1616
use Doctrine\ODM\PHPCR\Document\Generic;
1717
use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException;
18+
use Symfony\Cmf\Bundle\CoreBundle\Model\ChildInterface;
1819
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
1920
use Symfony\Cmf\Bundle\RoutingBundle\Model\Route as RouteModel;
2021

@@ -24,7 +25,7 @@
2425
*
2526
2627
*/
27-
class Route extends RouteModel implements PrefixInterface
28+
class Route extends RouteModel implements PrefixInterface, ChildInterface
2829
{
2930
/**
3031
* parent document
@@ -88,14 +89,32 @@ public function setAddTrailingSlash($addTrailingSlash)
8889
$this->addTrailingSlash = $addTrailingSlash;
8990
}
9091

92+
/**
93+
* @deprecated Use setParentDocument instead.
94+
*/
95+
public function setParent($parent)
96+
{
97+
$this->parent = $parent;
98+
99+
return $this;
100+
}
101+
102+
/**
103+
* @deprecated Use getParentDocument instead.
104+
*/
105+
public function getParent()
106+
{
107+
return $this->parent;
108+
}
109+
91110
/**
92111
* Move the route by setting a parent.
93112
*
94113
* Note that this will change the URL this route matches.
95114
*
96115
* @param object $parent the new parent document
97116
*/
98-
public function setParent($parent)
117+
public function setParentDocument($parent)
99118
{
100119
if (!is_object($parent)) {
101120
throw new InvalidArgumentException("Parent must be an object ".gettype ($parent)." given.");
@@ -112,7 +131,7 @@ public function setParent($parent)
112131
*
113132
* @return Generic object
114133
*/
115-
public function getParent()
134+
public function getParentDocument()
116135
{
117136
return $this->parent;
118137
}

Tests/Resources/DataFixtures/Phpcr/LoadRouteData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public function load(ObjectManager $manager)
3737
$manager->persist($parent);
3838

3939
$route = new Route;
40-
$route->setParent($parent);
40+
$route->setParentDocument($parent);
4141
$route->setName('route-1');
4242
$manager->persist($route);
4343

4444
$redirectRoute = new RedirectRoute;
45-
$redirectRoute->setParent($parent);
45+
$redirectRoute->setParentDocument($parent);
4646
$redirectRoute->setName('redirect-route-1');
4747
$manager->persist($redirectRoute);
4848

0 commit comments

Comments
 (0)