Skip to content

Commit 68fbfbf

Browse files
committed
Merge pull request #216 from gnat42/patch-1
Check parameter type
2 parents dce6ad8 + 1f31d7a commit 68fbfbf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doctrine/Phpcr/Route.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Doctrine\Common\Collections\Collection;
1616
use Doctrine\ODM\PHPCR\Document\Generic;
17+
use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException;
1718
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
1819
use Symfony\Cmf\Bundle\RoutingBundle\Model\Route as RouteModel;
1920

@@ -96,6 +97,10 @@ public function setAddTrailingSlash($addTrailingSlash)
9697
*/
9798
public function setParent($parent)
9899
{
100+
if (!is_object($parent)) {
101+
throw new InvalidArgumentException("Parent must be an object ".gettype ($parent)." given.");
102+
}
103+
99104
$this->parent = $parent;
100105

101106
return $this;
@@ -138,6 +143,10 @@ public function getName()
138143
*/
139144
public function setPosition($parent, $name)
140145
{
146+
if (!is_object($parent)) {
147+
throw new InvalidArgumentException("Parent must be an object ".gettype ($parent)." given.");
148+
}
149+
141150
$this->parent = $parent;
142151
$this->name = $name;
143152

0 commit comments

Comments
 (0)