Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitdad19bb

Browse files
committed
[FrameworkBundle][Routing] Add link to source to router:match
1 parentcda20aa commitdad19bb

File tree

5 files changed

+78
-2
lines changed

5 files changed

+78
-2
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
5.1.0
55
-----
66

7+
* Added link to source on controller on`router:match`/`debug:router` (when`framework.ide` is configured)
78
* Added`Routing\Loader` and`Routing\Loader\Configurator` namespaces to ease defining routes with default controllers
89
* Added the`framework.router.context` configuration node to configure the`RequestContext`
910
* Made`MicroKernelTrait::configureContainer()` compatible with`ContainerConfigurator`

‎src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
8282

8383
protectedfunctiondescribeRoute(Route$route,array$options = [])
8484
{
85+
$defaults =$route->getDefaults();
86+
if (!empty($defaults['_controller'])) {
87+
$defaults['_controller'] =$this->formatControllerLink($defaults['_controller'],$defaults['_controller']);
88+
}
89+
8590
$tableHeaders = ['Property','Value'];
8691
$tableRows = [
8792
['Route Name',isset($options['name']) ?$options['name'] :''],
@@ -93,7 +98,7 @@ protected function describeRoute(Route $route, array $options = [])
9398
['Method', ($route->getMethods() ?implode('|',$route->getMethods()) :'ANY')],
9499
['Requirements', ($route->getRequirements() ?$this->formatRouterConfig($route->getRequirements()) :'NO CUSTOM')],
95100
['Class',\get_class($route)],
96-
['Defaults',$this->formatRouterConfig($route->getDefaults())],
101+
['Defaults',$this->formatRouterConfig($defaults)],
97102
['Options',$this->formatRouterConfig($route->getOptions())],
98103
];
99104

‎src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/TextDescriptorTest.php‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
namespaceSymfony\Bundle\FrameworkBundle\Tests\Console\Descriptor;
1313

1414
useSymfony\Bundle\FrameworkBundle\Console\Descriptor\TextDescriptor;
15+
useSymfony\Component\HttpKernel\Debug\FileLinkFormatter;
16+
useSymfony\Component\Routing\Route;
1517

1618
class TextDescriptorTestextends AbstractDescriptorTest
1719
{
20+
private$fileLinkFormatter =null;
21+
1822
protectedfunctionsetUp():void
1923
{
2024
putenv('COLUMNS=121');
@@ -27,11 +31,41 @@ protected function tearDown(): void
2731

2832
protectedfunctiongetDescriptor()
2933
{
30-
returnnewTextDescriptor();
34+
returnnewTextDescriptor($this->fileLinkFormatter);
3135
}
3236

3337
protectedfunctiongetFormat()
3438
{
3539
return'txt';
3640
}
41+
42+
publicfunctiongetDescribeRouteWithControllerLinkTestData()
43+
{
44+
$getDescribeData =$this->getDescribeRouteTestData();
45+
46+
foreach ($getDescribeDataas$key => &$data) {
47+
$routeStub =$data[0];
48+
$routeStub->setDefault('_controller',sprintf('%s::%s', MyController::class,'__invoke'));
49+
$file =$data[2];
50+
$file =preg_replace('#(\..*?)$#','_link$1',$file);
51+
$data =file_get_contents(__DIR__.'/../../Fixtures/Descriptor/'.$file);
52+
$data = [$routeStub,$data,$file];
53+
}
54+
55+
return$getDescribeData;
56+
}
57+
58+
/** @dataProvider getDescribeRouteWithControllerLinkTestData */
59+
publicfunctiontestDescribeRouteWithControllerLink(Route$route,$expectedDescription)
60+
{
61+
$this->fileLinkFormatter =newFileLinkFormatter('myeditor://open?file=%f&line=%l');
62+
parent::testDescribeRoute($route,str_replace('[:file:]',__FILE__,$expectedDescription));
63+
}
64+
}
65+
66+
class MyController
67+
{
68+
publicfunction__invoke()
69+
{
70+
}
3771
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
+--------------+---------------------------------------------------------------------------------------------+
2+
| Property | Value |
3+
+--------------+---------------------------------------------------------------------------------------------+
4+
| Route Name | |
5+
| Path | /hello/{name} |
6+
| Path Regex | #PATH_REGEX# |
7+
| Host | localhost |
8+
| Host Regex | #HOST_REGEX# |
9+
| Scheme | http|https |
10+
| Method | GET|HEAD |
11+
| Requirements | name: [a-z]+ |
12+
| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub |
13+
| Defaults | _controller: ]8;;myeditor://open?file=[:file:]&line=68\Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\MyController::__invoke]8;;\ |
14+
| | name: Joseph |
15+
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
16+
| | opt1: val1 |
17+
| | opt2: val2 |
18+
+--------------+---------------------------------------------------------------------------------------------+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
+--------------+---------------------------------------------------------------------------------------------+
2+
| Property | Value |
3+
+--------------+---------------------------------------------------------------------------------------------+
4+
| Route Name | |
5+
| Path | /name/add |
6+
| Path Regex | #PATH_REGEX# |
7+
| Host | localhost |
8+
| Host Regex | #HOST_REGEX# |
9+
| Scheme | http|https |
10+
| Method | PUT|POST |
11+
| Requirements | NO CUSTOM |
12+
| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub |
13+
| Defaults | _controller: ]8;;myeditor://open?file=[:file:]&line=68\Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\MyController::__invoke]8;;\ |
14+
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15+
| | opt1: val1 |
16+
| | opt2: val2 |
17+
| Condition | context.getMethod() in ['GET', 'HEAD', 'POST'] |
18+
+--------------+---------------------------------------------------------------------------------------------+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp