8000 Add PHP config support for routing · symfony/web-profiler-bundle@ae50dd7 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae50dd7

Browse files
committed
Add PHP config support for routing
1 parent 2d55212 commit ae50dd7

File tree

6 files changed

+77
-57
lines changed

6 files changed

+77
-57
lines changed

CHANGELOG.md

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

7+
* Add `profiler.php` and `wdt.php` routing configuration files (use them instead of their XML equivalent)
78
* Add `ajax_replace` option for replacing toolbar on AJAX requests
89

910
7.2

Resources/config/routing/profiler.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
13+
14+
return function (RoutingConfigurator $routes): void {
15+
$routes->add('_profiler_home', '/')
16+
->controller('web_profiler.controller.profiler::homeAction')
17+
;
18+
$routes->add('_profiler_search', '/search')
19+
->controller('web_profiler.controller.profiler::searchAction')
20+
;
21+
$routes->add('_profiler_search_bar', '/search_bar')
22+
->controller('web_profiler.controller.profiler::searchBarAction')
23+
;
24+
$routes->add('_profiler_phpinfo', '/phpinfo')
25+
->controller('web_profiler.controller.profiler::phpinfoAction')
26+
;
27+
$routes->add('_profiler_xdebug', '/xdebug')
28+
->controller('web_profiler.controller.profiler::xdebugAction')
29+
;
30+
$routes-> 10000 ;add('_profiler_font', '/font/{fontName}.woff2')
31+
->controller('web_profiler.controller.profiler::fontAction')
32+
;
33+
$routes->add('_profiler_search_results', '/{token}/search/results')
34+
->controller('web_profiler.controller.profiler::searchResultsAction')
35+
;
36+
$routes->add('_profiler_open_file', '/open')
37+
->controller('web_profiler.controller.profiler::openAction')
38+
;
39+
$routes->add('_profiler', '/{token}')
40+
->controller('web_profiler.controller.profiler::panelAction')
41+
;
42+
$routes->add('_profiler_router', '/{token}/router')
43+
->controller('web_profiler.controller.router::panelAction')
44+
;
45+
$routes->add('_profiler_exception', '/{token}/exception')
46+
->controller('web_profiler.controller.exception_panel::body')
47+
;
48+
$routes->add('_profiler_exception_css', '/{token}/exception.css')
49+
->controller('web_profiler.controller.exception_panel::stylesheet')
50+
;
51+
};

Resources/config/routing/profiler.xml

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,5 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<route id="_profiler_home" path="/">
8-
<default key="_controller">web_profiler.controller.profiler::homeAction</default>
9-
</route>
10-
11-
<route id="_profiler_search" path="/search">
12-
<default key="_controller">web_profiler.controller.profiler::searchAction</default>
13-
</route>
14-
15-
<route id="_profiler_search_bar" path="/search_bar">
16-
<default key="_controller">web_profiler.controller.profiler::searchBarAction</default>
17-
</route>
18-
19-
<route id="_profiler_phpinfo" path="/phpinfo">
20-
<default key="_controller">web_ 67F4 profiler.controller.profiler::phpinfoAction</default>
21-
</route>
22-
23-
<route id="_profiler_xdebug" path="/xdebug">
24-
<default key="_controller">web_profiler.controller.profiler::xdebugAction</default>
25-
</route>
26-
27-
<route id="_profiler_font" path="/font/{fontName}.woff2">
28-
<default key="_controller">web_profiler.controller.profiler::fontAction</default>
29-
</route>
30-
31-
<route id="_profiler_search_results" path="/{token}/search/results">
32-
<default key="_controller">web_profiler.controller.profiler::searchResultsAction</default>
33-
</route>
34-
35-
<route id="_profiler_open_file" path="/open">
36-
<default key="_controller">web_profiler.controller.profiler::openAction</default>
37-
</route>
38-
39-
<route id="_profiler" path="/{token}">
40-
<default key="_controller">web_profiler.controller.profiler::panelAction</default>
41-
</route>
42-
43-
<route id="_profiler_router" path="/{token}/router">
44-
<default key="_controller">web_profiler.controller.router::panelAction</default>
45-
</route>
46-
47-
<route id="_profiler_exception" path="/{token}/exception">
48-
<default key="_controller">web_profiler.controller.exception_panel::body</default>
49-
</route>
50-
51-
<route id="_profiler_exception_css" path="/{token}/exception.css">
52-
<default key="_controller">web_profiler.controller.exception_panel::stylesheet</default>
53-
</route>
54-
7+
<import resource="profiler.php" type="php" />
558
</routes>

Resources/config/routing/wdt.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
13+
14+
return function (RoutingConfigurator $routes): void {
15+
$routes->add('_wdt_stylesheet', '/styles')
16+
->controller('web_profiler.controller.profiler::toolbarStylesheetAction')
17+
;
18+
$routes->add('_wdt', '/{token}')
19+
->controller('web_profiler.controller.profiler::toolbarAction')
20+
;
21+
};

Resources/config/routing/wdt.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,5 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<route id="_wdt_stylesheet" path="/styles">
8-
<default key="_controller">web_profiler.controller.profiler::toolbarStylesheetAction</default>
9-
</route>
10-
11-
<route id="_wdt" path="/{token}">
12-
<default key="_controller">web_profiler.controller.profiler::toolbarAction</default>
13-
</route>
7+
<import resource="wdt.php" type="php" />
148
</routes>

Tests/Functional/WebProfilerBundleKernel.php

Lines changed: 2 additions & 2 deletions
< 5CE1 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function registerBundles(): iterable
4343

4444
protected function configureRoutes(RoutingConfigurator $routes): void
4545
{
46-
$routes->import(__DIR__.'/../../Resources/config/routing/profiler.xml')->prefix('/_profiler');
47-
$routes->import(__DIR__.'/../../Resources/config/routing/wdt.xml')->prefix('/_wdt');
46+
$routes->import(__DIR__.'/../../Resources/config/routing/profiler.php')->prefix('/_profiler');
47+
$routes->import(__DIR__.'/../../Resources/config/routing/wdt.php')->prefix('/_wdt');
4848
$routes->add('_', '/')->controller('kernel::homepageController');
4949
}
5050

0 commit comments

Comments
 (0)
0