Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98f82fe

Browse filesBrowse files
[FrameworkBundle] fix removing "action" from route names
1 parent 63e4269 commit 98f82fe
Copy full SHA for 98f82fe

File tree

3 files changed

+19
-9
lines changed
Filter options

3 files changed

+19
-9
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ protected function configureRoute(Route $route, \ReflectionClass $class, \Reflec
4343
*/
4444
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
4545
{
46-
return preg_replace([
47-
'/(bundle|controller)_/',
48-
'/action(_\d+)?$/',
49-
'/__/',
50-
], [
51-
'_',
52-
'\\1',
53-
'_',
54-
], parent::getDefaultRouteName($class, $method));
46+
$name = preg_replace('/(bundle|controller)_/', '_', parent::getDefaultRouteName($class, $method));
47+
48+
if ('Action' === substr($method->name, -6) || '_action' === substr($method->name, -7)) {
49+
$name = preg_replace('/action(_\d+)?$/', '\\1', $name);
50+
}
51+
52+
return str_replace('__', '_', $name);
5553
}
5654
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public function testAnnotatedController($path, $expectedValue)
2323

2424
$this->assertSame(200, $client->getResponse()->getStatusCode());
2525
$this->assertSame($expectedValue, $client->getResponse()->getContent());
26+
27+
$router = self::$container->get('router');
28+
29+
$this->assertSame('/annotated/create-transaction', $router->generate('symfony_framework_tests_functional_test_annotated_createtransaction'));
2630
}
2731

2832
public function getRoutes()

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ public function argumentWithoutDefaultWithRouteParamAndDefaultAction($value)
4848
{
4949
return new Response($value);
5050
}
51+
52+
/**
53+
* @Route("/create-transaction")
54+
*/
55+
public function createTransaction($value)
56+
{
57+
return new Response($value);
58+
}
5159
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.