Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ProviderBasedGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function generate($name, $parameters = [], $referenceType = self::ABSOLUT
&& $parameters[RouteObjectInterface::ROUTE_OBJECT] instanceof SymfonyRoute
) {
$route = $parameters[RouteObjectInterface::ROUTE_OBJECT];
unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
} elseif (null === $route = $this->provider->getRouteByName($name)) {
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
}
Expand Down
22 changes: 21 additions & 1 deletion tests/Unit/Routing/ProviderBasedGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\Route as SymfonyRoute;

class ProviderBasedGeneratorTest extends TestCase
{
Expand Down Expand Up @@ -106,6 +107,15 @@ public function testGenerateFromRoute(): void
$this->assertEquals('result_url', $url);
}

public function testRemoveRouteObject(): void
{
$url = $this->generator->generate(RouteObjectInterface::OBJECT_BASED_ROUTE_NAME, [
RouteObjectInterface::ROUTE_OBJECT => new Proxy('/path'),
]);

$this->assertEquals('result_url', $url);
}

/**
* @group legacy
*
Expand Down Expand Up @@ -172,7 +182,12 @@ class TestableProviderBasedGenerator extends ProviderBasedGenerator
{
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
{
return 'result_url';
$url = 'result_url';
if ($parameters && $query = http_build_query($parameters, '', '&', PHP_QUERY_RFC3986)) {
$url .= '?'.$query;
}

return $url;
}
}

Expand All @@ -188,3 +203,8 @@ public function getContent(): ?object
return null;
}
}

class Proxy extends SymfonyRoute
{
public $__isInitialized__ = true;
}