Skip to content

Commit 92ae2c5

Browse files
committed
Merge pull request #158 from rande/use_url_generator_interface
Use UrlGeneratorInterface constants
2 parents 289fc0d + 5a93dfc commit 92ae2c5

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

ChainRouter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function doMatch($url, Request $request = null)
211211
* Loops through all registered routers and returns a router if one is found.
212212
* It will always return the first route generated.
213213
*/
214-
public function generate($name, $parameters = array(), $absolute = false)
214+
public function generate($name, $parameters = array(), $absolute = UrlGeneratorInterface::ABSOLUTE_PATH)
215215
{
216216
$debug = array();
217217

@@ -309,7 +309,7 @@ public function getRouteCollection()
309309

310310
/**
311311
* Identify if any routers have been added into the chain yet
312-
*
312+
*
313313
* @return boolean
314314
*/
315315
public function hasRouters()

ContentAwareGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Cmf\Component\Routing;
1313

1414
use Doctrine\Common\Collections\Collection;
15+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1516
use Symfony\Component\Routing\Route as SymfonyRoute;
1617
use Symfony\Component\Routing\Exception\RouteNotFoundException;
1718
use Symfony\Component\Routing\RouteCollection;
@@ -65,7 +66,7 @@ public function setContentRepository(ContentRepositoryInterface $contentReposito
6566
*
6667
* @throws RouteNotFoundException If there is no such route in the database
6768
*/
68-
public function generate($name, $parameters = array(), $absolute = false)
69+
public function generate($name, $parameters = array(), $absolute = UrlGeneratorInterface::ABSOLUTE_PATH)
6970
{
7071
if ($name instanceof SymfonyRoute) {
7172
$route = $this->getBestLocaleRoute($name, $parameters);

ProviderBasedGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Cmf\Component\Routing;
1313

1414
use Symfony\Component\Routing\Generator\UrlGenerator;
15+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1516
use Symfony\Component\Routing\Route as SymfonyRoute;
1617
use Symfony\Component\Routing\RequestContext;
1718
use Symfony\Component\Routing\Exception\RouteNotFoundException;
@@ -46,7 +47,7 @@ public function __construct(RouteProviderInterface $provider, LoggerInterface $l
4647
/**
4748
* {@inheritDoc}
4849
*/
49-
public function generate($name, $parameters = array(), $absolute = false)
50+
public function generate($name, $parameters = array(), $absolute = UrlGeneratorInterface::ABSOLUTE_PATH)
5051
{
5152
if ($name instanceof SymfonyRoute) {
5253
$route = $name;

Tests/Routing/ChainRouterTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
1717
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
1818
use Symfony\Component\Routing\Exception\RouteNotFoundException;
19+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1920
use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
2021
use Symfony\Component\Routing\RequestContext;
2122
use Symfony\Component\Routing\RouteCollection;
@@ -506,13 +507,13 @@ public function testGenerate()
506507
$high
507508
->expects($this->once())
508509
->method('generate')
509-
->with($name, $parameters, false)
510+
->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH)
510511
->will($this->throwException(new RouteNotFoundException()))
511512
;
512513
$low
513514
->expects($this->once())
514515
->method('generate')
515-
->with($name, $parameters, false)
516+
->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH)
516517
->will($this->returnValue($url))
517518
;
518519
$lower
@@ -539,12 +540,12 @@ public function testGenerateNotFound()
539540
$high
540541
->expects($this->once())
541542
->method('generate')
542-
->with($name, $parameters, false)
543+
->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH)
543544
->will($this->throwException(new RouteNotFoundException()))
544545
;
545546
$low->expects($this->once())
546547
->method('generate')
547-
->with($name, $parameters, false)
548+
->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH)
548549
->will($this->throwException(new RouteNotFoundException()))
549550
;
550551
$this->router->add($low, 10);
@@ -593,7 +594,7 @@ public function testGenerateObjectNotFoundVersatile()
593594
;
594595
$chainedRouter->expects($this->once())
595596
->method('generate')
596-
->with($name, $parameters, false)
597+
->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH)
597598
->will($this->throwException(new RouteNotFoundException()))
598599
;
599600
$chainedRouter->expects($this->once())
@@ -627,7 +628,7 @@ public function testGenerateObjectName()
627628
$chainedRouter
628629
->expects($this->once())
629630
->method('generate')
630-
->with($name, $parameters, false)
631+
->with($name, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH)
631632
->will($this->returnValue($name))
632633
;
633634

Tests/Routing/DynamicRouterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Cmf\Component\Routing\Event\Events;
1515
use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent;
1616
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1718
use Symfony\Component\Routing\RouteCollection;
1819

1920
use Symfony\Cmf\Component\Routing\DynamicRouter;
@@ -89,7 +90,7 @@ public function testGenerate()
8990
{
9091
$name = 'my_route_name';
9192
$parameters = array('foo' => 'bar');
92-
$absolute = true;
93+
$absolute = UrlGeneratorInterface::ABSOLUTE_PATH;
9394

9495
$this->generator->expects($this->once())
9596
->method('generate')

0 commit comments

Comments
 (0)