Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cafdf2b

Browse files
javiereguiluznicolas-grekas
authored andcommitted
[WebProfilerBundle] Deprecated the web_profiler.position option
1 parent 8357f2a commit cafdf2b

File tree

13 files changed

+23
-88
lines changed

13 files changed

+23
-88
lines changed

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ CHANGELOG
66

77
* removed the `WebProfilerExtension::dumpValue()` method
88
* removed the `getTemplates()` method of the `TemplateManager` class in favor of the ``getNames()`` method
9+
* removed the `web_profiler.position` config option and the
10+
`web_profiler.debug_toolbar.position` container parameter
911

1012
3.1.0
1113
-----

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,25 @@ class ProfilerController
3434
private $profiler;
3535
private $twig;
3636
private $templates;
37-
private $toolbarPosition;
3837
private $cspHandler;
3938
private $baseDir;
4039

4140
/**
4241
* Constructor.
4342
*
44-
* @param UrlGeneratorInterface $generator The URL Generator
45-
* @param Profiler $profiler The profiler
46-
* @param Environment $twig The twig environment
47-
* @param array $templates The templates
48-
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
49-
* @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler
50-
* @param string $baseDir The project root directory
43+
* @param UrlGeneratorInterface $generator The URL Generator
44+
* @param Profiler $profiler The profiler
45+
* @param Environment $twig The twig environment
46+
* @param array $templates The templates
47+
* @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler
48+
* @param string $baseDir The project root directory
5149
*/
52-
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, $toolbarPosition = 'bottom', ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null)
50+
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null)
5351
{
5452
$this->generator = $generator;
5553
$this->profiler = $profiler;
5654
$this->twig = $twig;
5755
$this->templates = $templates;
58-
$this->toolbarPosition = $toolbarPosition;
5956
$this->cspHandler = $cspHandler;
6057
$this->baseDir = $baseDir;
6158
}
@@ -161,11 +158,6 @@ public function toolbarAction(Request $request, $token)
161158
return new Response('', 404, array('Content-Type' => 'text/html'));
162159
}
163160

164-
// the toolbar position (top, bottom, normal, or null -- use the configuration)
165-
if (null === $position = $request->query->get('position')) {
166-
$position = $this->toolbarPosition;
167-
}
168-
169161
$url = null;
170162
try {
171163
$url = $this->generator->generate('_profiler', array('token' => $token));
@@ -175,7 +167,6 @@ public function toolbarAction(Request $request, $token)
175167

176168
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', array(
177169
'request' => $request,
178-
'position' => $position,
179170
'profile' => $profile,
180171
'templates' => $this->getTemplateManager()->getNames($profile),
181172
'profiler_url' => $url,

src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ public function getConfigTreeBuilder()
3737
$rootNode
3838
->children()
3939
->booleanNode('toolbar')->defaultFalse()->end()
40-
->scalarNode('position')
41-
->defaultValue('bottom')
42-
->setDeprecated('The "web_profiler.position" configuration key has been deprecated in Symfony 3.4 and it will be removed in 4.0.')
43-
->validate()
44-
->ifNotInArray(array('bottom', 'top'))
45-
->thenInvalid('The CSS position %s is not supported')
46-
->end()
47-
->end()
4840
->booleanNode('intercept_redirects')->defaultFalse()->end()
4941
->scalarNode('excluded_ajax_paths')->defaultValue('^/(app(_[\\w]+)?\\.php/)?_wdt')->end()
5042
->end()

src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ public function load(array $configs, ContainerBuilder $container)
4444

4545
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
4646
$loader->load('profiler.xml');
47-
$container->setParameter('web_profiler.debug_toolbar.position', $config['position']);
4847

4948
if ($config['toolbar'] || $config['intercept_redirects']) {
5049
$loader->load('toolbar.xml');
51-
$container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(5, $config['excluded_ajax_paths']);
50+
$container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(4, $config['excluded_ajax_paths']);
5251
$container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']);
5352
$container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
5453
}
@@ -66,7 +65,7 @@ public function load(array $configs, ContainerBuilder $container)
6665
$baseDir = implode(DIRECTORY_SEPARATOR, $baseDir);
6766

6867
$profilerController = $container->getDefinition('web_profiler.controller.profiler');
69-
$profilerController->replaceArgument(6, $baseDir);
68+
$profilerController->replaceArgument(5, $baseDir);
7069

7170
$fileLinkFormatter = $container->getDefinition('debug.file_link_formatter');
7271
$fileLinkFormatter->replaceArgument(2, $baseDir);

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@ class WebDebugToolbarListener implements EventSubscriberInterface
4040
protected $urlGenerator;
4141
protected $interceptRedirects;
4242
protected $mode;
43-
protected $position;
4443
protected $excludedAjaxPaths;
4544
private $cspHandler;
4645

47-
public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, $position = 'bottom', UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null)
46+
public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null)
4847
{
4948
$this->twig = $twig;
5049
$this->urlGenerator = $urlGenerator;
5150
$this->interceptRedirects = (bool) $interceptRedirects;
5251
$this->mode = (int) $mode;
53-
$this->position = $position;
5452
$this->excludedAjaxPaths = $excludedAjaxPaths;
5553
$this->cspHandler = $cspHandler;
5654
}
@@ -124,7 +122,6 @@ protected function injectToolbar(Response $response, Request $request, array $no
124122
$toolbar = "\n".str_replace("\n", '', $this->twig->render(
125123
'@WebProfiler/Profiler/toolbar_js.html.twig',
126124
array(
127-
'position' => $this->position,
128125
'excluded_ajax_paths' => $this->excludedAjaxPaths,
129126
'token' => $response->headers->get('X-Debug-Token'),
130127
'request' => $request,

src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<argument type="service" id="profiler" on-invalid="null" />
1313
<argument type="service" id="twig" />
1414
<argument>%data_collector.templates%</argument>
15-
<argument>%web_profiler.debug_toolbar.position%</argument>
1615
<argument type="service" id="web_profiler.csp.handler" />
1716
<argument>null</argument>
1817
</service>

src/Symfony/Bundle/WebProfilerBundle/Resources/config/schema/webprofiler-1.0.xsd

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,5 @@
1010
<xsd:complexType name="config">
1111
<xsd:attribute name="toolbar" type="xsd:boolean" />
1212
<xsd:attribute name="intercept-redirects" type="xsd:boolean" />
13-
<xsd:attribute name="position" type="positions" />
1413
</xsd:complexType>
15-
16-
<xsd:simpleType name="positions">
17-
<xsd:restriction base="xsd:string">
18-
<xsd:enumeration value="top"/>
19-
<xsd:enumeration value="bottom"/>
20-
</xsd:restriction>
21-
</xsd:simpleType>
2214
</xsd:schema>

src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<argument type="service" id="twig" />
1313
<argument>%web_profiler.debug_toolbar.intercept_redirects%</argument>
1414
<argument>%web_profiler.debug_toolbar.mode%</argument>
15-
<argument>%web_profiler.debug_toolbar.position%</argument>
1615
<argument type="service" id="router" on-invalid="ignore" />
1716
<argument /> <!-- paths that should be excluded from the AJAX requests shown in the toolbar -->
1817
<argument type="service" id="web_profiler.csp.handler" />

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -416,34 +416,6 @@
416416
display: none;
417417
}
418418

419-
/* Override the setting when the toolbar is on the top */
420-
{% if position == 'top' %}
421-
.sf-minitoolbar {
422-
border-bottom-left-radius: 4px;
423-
border-top-left-radius: 0;
424-
bottom: auto;
425-
right: 0;
426-
top: 0;
427-
}
428-
429-
.sf-toolbarreset {
430-
bottom: auto;
431-
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
432-
top: 0;
433-
}
434-
435-
.sf-toolbar-block .sf-toolbar-info {
436-
bottom: auto;
437-
top: 36px;
438-
}
439-
{% endif %}
440-
441-
{% if not floatable %}
442-
.sf-toolbarreset {
443-
position: static;
444-
}
445-
{% endif %}
446-
447419
/* Responsive Design */
448420
.sf-toolbar-icon .sf-toolbar-label,
449421
.sf-toolbar-icon .sf-toolbar-value {

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
<div id="sfwdt{{ token }}" class="sf-toolbar sf-display-none"></div>
22
{{ include('@WebProfiler/Profiler/base_js.html.twig') }}
33
<style{% if csp_style_nonce %} nonce="{{ csp_style_nonce }}"{% endif %}>
4-
{{ include('@WebProfiler/Profiler/toolbar.css.twig', { 'position': position, 'floatable': true }) }}
4+
{{ include('@WebProfiler/Profiler/toolbar.css.twig') }}
55
</style>
66
<script{% if csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
77
(function () {
8-
{% if 'top' == position %}
9-
var sfwdt = document.getElementById('sfwdt{{ token }}');
10-
document.body.insertBefore(
11-
document.body.removeChild(sfwdt),
12-
document.body.firstChild
13-
);
14-
{% endif %}
15-
168
Sfjs.load(
179
'sfwdt{{ token }}',
1810
'{{ path("_wdt", { "token": token }) }}',

src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function createController($profiler, $twig, $withCSP)
157157
if ($withCSP) {
158158
$nonceGenerator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock();
159159

160-
return new ProfilerController($urlGenerator, $profiler, $twig, array(), 'bottom', new ContentSecurityPolicyHandler($nonceGenerator));
160+
return new ProfilerController($urlGenerator, $profiler, $twig, array(), new ContentSecurityPolicyHandler($nonceGenerator));
161161
}
162162

163163
return new ProfilerController($urlGenerator, $profiler, $twig, array());

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public function testConfigTree($options, $results)
3232
public function getDebugModes()
3333
{
3434
return array(
35-
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
36-
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
37-
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
38-
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
39-
array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'top', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
40-
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => 'test')),
35+
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
36+
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
37+
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
38+
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
39+
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
40+
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => 'test')),
4141
);
4242
}
4343
}

src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function testXDebugUrlHeader()
219219

220220
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
221221

222-
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
222+
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
223223
$listener->onKernelResponse($event);
224224

225225
$this->assertEquals('http://mydomain.com/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
@@ -240,7 +240,7 @@ public function testThrowingUrlGenerator()
240240

241241
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
242242

243-
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
243+
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
244244
$listener->onKernelResponse($event);
245245

246246
$this->assertEquals('Exception: foo', $response->headers->get('X-Debug-Error'));
@@ -261,7 +261,7 @@ public function testThrowingErrorCleanup()
261261

262262
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
263263

264-
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
264+
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
265265
$listener->onKernelResponse($event);
266266

267267
$this->assertEquals('Exception: This multiline tabbed text should come out on a single plain line', $response->headers->get('X-Debug-Error'));

0 commit comments

Comments
 (0)