Skip to content

Commit fe91a80

Browse files
committed
symfony 2.2 can have any string as route name. fix symfony#49
1 parent 72df1da commit fe91a80

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ChainRouter.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,14 @@ public function generate($name, $parameters = array(), $absolute = false)
199199
/** @var $router RouterInterface */
200200
foreach ($this->all() as $router) {
201201

202-
// if $name and $router does not implement ChainedRouterInterface and $name is not a string, continue
203-
// if $name and $router does not implement ChainedRouterInterface and $name is string but does not match a default Symfony2 route name, continue
202+
// if $router does not implement ChainedRouterInterface and $name is not a string, continue
203+
// if $router does not implement ChainedRouterInterface and $name is string, but does not match a valid Symfony2.1 route name, continue
204204
if ($name && !$router instanceof ChainedRouterInterface) {
205-
if (!is_string($name) || !preg_match(VersatileGeneratorInterface::CORE_NAME_PATTERN, $name)) {
205+
if (! is_string($name)
206+
|| (! class_exists('Symfony\Component\Routing\Matcher\Dumper\DumperRoute') // only Symfony 2.2
207+
&& ! preg_match(VersatileGeneratorInterface::CORE_NAME_PATTERN, $name)
208+
)
209+
) {
206210
continue;
207211
}
208212
}

VersatileGeneratorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
interface VersatileGeneratorInterface extends UrlGeneratorInterface
1212
{
1313
/**
14-
* If $name preg_match this pattern, the name is valid for symfony core
15-
* compatible generators.
14+
* If $name preg_match this pattern, the name is valid for symfony 2.1 core
15+
* compatible generators. In 2.2 the pattern may be any string.
1616
*/
1717
const CORE_NAME_PATTERN = '/^[a-z0-9A-Z_.]+$/';
1818

0 commit comments

Comments
 (0)