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 7f4a84f

Browse filesBrowse files
[FrameworkBundle] fix removing "action" from route names
1 parent b19200c commit 7f4a84f
Copy full SHA for 7f4a84f

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
@@ -41,14 +41,12 @@ protected function configureRoute(Route $route, \ReflectionClass $class, \Reflec
4141
*/
4242
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
4343
{
44-
return preg_replace([
45-
'/(bundle|controller)_/',
46-
'/action(_\d+)?$/',
47-
'/__/',
48-
], [
49-
'_',
50-
'\\1',
51-
'_',
52-
], parent::getDefaultRouteName($class, $method));
44+
$name = preg_replace('/(bundle|controller)_/', '_', parent::getDefaultRouteName($class, $method));
45+
46+
if (str_ends_with($method->name, 'Action') || str_ends_with($method->name, '_action')) {
47+
$name = preg_replace('/action(_\d+)?$/', '\\1', $name);
48+
}
49+
50+
return str_replace('__', '_', $name);
5351
}
5452
}

‎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()
56+
{
57+
return new Response();
58+
}
5159
}

0 commit comments

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