Skip to content

Commit

Permalink
Merge pull request #81 from symfony-cmf/remove_to_string
Browse files Browse the repository at this point in the history
remove reliance on __toString()
  • Loading branch information
dbu committed Sep 1, 2013
2 parents 601edfc + 0ff2e7f commit c0f8fcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ContentAwareGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function getRouteDebugMessage($name, array $parameters = array())
}

if ($name instanceof RouteReferrersReadInterface) {
return 'Route aware content ' . $name;
return 'Route aware content ' . parent::getRouteDebugMessage($name, $parameters);
}

return parent::getRouteDebugMessage($name, $parameters);
Expand Down
10 changes: 9 additions & 1 deletion ProviderBasedGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public function supports($name)
*/
public function getRouteDebugMessage($name, array $parameters = array())
{
if (is_scalar($name)) {
return $name;
}

if (is_array($name)) {
return serialize($name);
}

if ($name instanceof RouteObjectInterface) {
return 'Route with key ' . $name->getRouteKey();
}
Expand All @@ -73,7 +81,7 @@ public function getRouteDebugMessage($name, array $parameters = array())
return 'Route with pattern ' . $name->getPattern();
}

return $name;
return get_class($name);
}

}
6 changes: 1 addition & 5 deletions Tests/Routing/ContentAwareGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function testSupports()
public function testGetRouteDebugMessage()
{
$this->assertContains('/some/content', $this->generator->getRouteDebugMessage(null, array('content_id' => '/some/content')));
$this->assertContains('/some/content', $this->generator->getRouteDebugMessage(new RouteAware()));
$this->assertContains('Route aware content Symfony\Cmf\Component\Routing\Tests\Routing\RouteAware', $this->generator->getRouteDebugMessage(new RouteAware()));
$this->assertContains('/some/content', $this->generator->getRouteDebugMessage('/some/content'));
}
}
Expand All @@ -413,8 +413,4 @@ public function getRoutes()
{
return array();
}
public function __toString()
{
return '/some/content';
}
}

0 comments on commit c0f8fcb

Please sign in to comment.