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: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ cache:
- $HOME/.composer/cache

env:
matrix: SYMFONY_VERSION=4.0.*
global:
- SYMFONY_PHPUNIT_VERSION=6
- COMPOSER_MEMORY_LIMIT=-1
Expand Down
10 changes: 9 additions & 1 deletion src/ChainRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,21 @@ private function doMatch($pathinfo, Request $request = null)
/**
* {@inheritdoc}
*
* @param mixed $name
*
* The CMF routing system used to allow to pass route objects as $name to generate the route.
* Since Symfony 5.0, the UrlGeneratorInterface declares $name as string. We widen the contract
* for BC but deprecate passing non-strings.
* Instead, Pass the RouteObjectInterface::OBJECT_BASED_ROUTE_NAME as route name and the object
* in the parameters with key RouteObjectInterface::ROUTE_OBJECT.
*
* Loops through all registered routers and returns a router if one is found.
* It will always return the first route generated.
*/
public function generate($name, $parameters = [], $absolute = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if (is_object($name)) {
@trigger_error('Passing an object as route name is deprecated since version 2.3 and will not work in Symfony 5.0. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.', E_USER_DEPRECATED);
@trigger_error('Passing an object as route name is deprecated since version 2.3. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.', E_USER_DEPRECATED);
}

$debug = [];
Expand Down
23 changes: 15 additions & 8 deletions src/ContentAwareGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,25 @@ public function setContentRepository(ContentRepositoryInterface $contentReposito
/**
* {@inheritdoc}
*
* @param string $name ignored
* @param array $parameters must either contain the field 'route' with a
* RouteObjectInterface or the field 'content_id'
* with the id of a document implementing
* RouteReferrersReadInterface
* The CMF routing system used to allow to pass route objects as $name to generate the route.
* Since Symfony 5.0, the UrlGeneratorInterface declares $name as string. We widen the contract
* for BC but deprecate passing non-strings.
* Instead, Pass the RouteObjectInterface::OBJECT_BASED_ROUTE_NAME as route name and the object
* in the parameters with key RouteObjectInterface::ROUTE_OBJECT or the ID of a
* RouteReferrersReadInterface in 'content_id.
*
* @param mixed $name ignored
* @param array $parameters must either contain the field 'route' with a
* RouteObjectInterface or the field 'content_id'
* with the id of a document implementing
* RouteReferrersReadInterface
*
* @throws RouteNotFoundException If there is no such route in the database
*/
public function generate($name, $parameters = [], $absolute = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if ($name instanceof SymfonyRoute) {
@trigger_error('Passing an object as route name is deprecated since version 2.3 and will not work in Symfony 5.0. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.', E_USER_DEPRECATED);
@trigger_error('Passing an object as route name is deprecated since version 2.3. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT` resp the content id with content_id.', E_USER_DEPRECATED);

$route = $this->getBestLocaleRoute($name, $parameters);
} elseif (RouteObjectInterface::OBJECT_BASED_ROUTE_NAME === $name) {
Expand Down Expand Up @@ -172,7 +179,7 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters)
protected function getRouteByContent($name, &$parameters)
{
if ($name instanceof RouteReferrersReadInterface) {
@trigger_error('Passing an object as route name is deprecated since version 2.3 and will not work in Symfony 5.0. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.', E_USER_DEPRECATED);
@trigger_error('Passing an object as route name is deprecated since version 2.3. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.', E_USER_DEPRECATED);

$content = $name;
} elseif (RouteObjectInterface::OBJECT_BASED_ROUTE_NAME === $name
Expand All @@ -193,7 +200,7 @@ protected function getRouteByContent($name, &$parameters)
} else {
$hint = is_object($name) ? get_class($name) : gettype($name);

throw new RouteNotFoundException("The route name argument '$hint' is not RouteReferrersReadInterface instance and there is no 'content_id' parameter");
throw new RouteNotFoundException("The route name argument '$hint' is not a RouteReferrersReadInterface instance and there is no 'content_id' parameter");
}

$routes = $content->getRoutes();
Expand Down
14 changes: 7 additions & 7 deletions src/DynamicRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,20 @@ public function getGenerator()
* If the generator is not able to generate the url, it must throw the
* RouteNotFoundException as documented below.
*
* @param string|Route $name The name of the route or the Route instance
* @param mixed $parameters An array of parameters
* @param bool|string $referenceType The type of reference to be generated (one of the constants in UrlGeneratorInterface)
* The CMF routing system used to allow to pass route objects as $name to generate the route.
* Since Symfony 5.0, the UrlGeneratorInterface declares $name as string. We widen the contract
* for BC but deprecate passing non-strings.
* Instead, Pass the RouteObjectInterface::OBJECT_BASED_ROUTE_NAME as route name and the object
* in the parameters with key RouteObjectInterface::ROUTE_OBJECT.
*
* @return string The generated URL
* @param string|Route $name The name of the route or the Route instance
*
* @throws RouteNotFoundException if route doesn't exist
*
* @api
*/
public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if (is_object($name)) {
@trigger_error('Passing an object as route name is deprecated since version 2.3 and will not work in Symfony 5.0. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT', E_USER_DEPRECATED);
@trigger_error('Passing an object as route name is deprecated since version 2.3. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT', E_USER_DEPRECATED);
}

if ($this->eventDispatcher) {
Expand Down
2 changes: 1 addition & 1 deletion src/RouteObjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ interface RouteObjectInterface
* If there is no specific content for this url (i.e. its an "application"
* page), may return null.
*
* @return object the document or entity this route entry points to
* @return null|object the document or entity this route entry points to
*/
public function getContent();

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Routing/ChainRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ public function testGenerateNotFound()
* Route is an object but no versatile generator around to do the debug message.
*
* @group legacy
* @expectedDeprecation Passing an object as route name is deprecated since version 2.3 and will not work in Symfony 5.0. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.
* @expectedDeprecation Passing an object as route name is deprecated since version 2.3. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.
*/
public function testGenerateObjectNotFound()
{
Expand Down Expand Up @@ -645,7 +645,7 @@ public function testGenerateObjectNotFound()
* A versatile router will generate the debug message.
*
* @group legacy
* @expectedDeprecation Passing an object as route name is deprecated since version 2.3 and will not work in Symfony 5.0. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.
* @expectedDeprecation Passing an object as route name is deprecated since version 2.3. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.
*/
public function testGenerateObjectNotFoundVersatile()
{
Expand Down Expand Up @@ -681,7 +681,7 @@ public function testGenerateObjectNotFoundVersatile()

/**
* @group legacy
* @expectedDeprecation Passing an object as route name is deprecated since version 2.3 and will not work in Symfony 5.0. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.
* @expectedDeprecation Passing an object as route name is deprecated since version 2.3. Pass the `RouteObjectInterface::OBJECT_BASED_ROUTE_NAME` as route name and the object in the parameters with key `RouteObjectInterface::ROUTE_OBJECT`.
*/
public function testGenerateObjectName()
{
Expand Down
Loading