Skip to content

[WebProfilerBundle] Removed the deprecated web_profiler.position option #23728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CHANGELOG

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

3.1.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,25 @@ class ProfilerController
private $profiler;
private $twig;
private $templates;
private $toolbarPosition;
private $cspHandler;
private $baseDir;

/**
* Constructor.
*
* @param UrlGeneratorInterface $generator The URL Generator
* @param Profiler $profiler The profiler
* @param Environment $twig The twig environment
* @param array $templates The templates
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
* @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler
* @param string $baseDir The project root directory
* @param UrlGeneratorInterface $generator The URL Generator
* @param Profiler $profiler The profiler
* @param Environment $twig The twig environment
* @param array $templates The templates
* @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler
* @param string $baseDir The project root directory
*/
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, $toolbarPosition = 'bottom', ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null)
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null)
{
$this->generator = $generator;
$this->profiler = $profiler;
$this->twig = $twig;
$this->templates = $templates;
$this->toolbarPosition = $toolbarPosition;
$this->cspHandler = $cspHandler;
$this->baseDir = $baseDir;
}
Expand Down Expand Up @@ -161,11 +158,6 @@ public function toolbarAction(Request $request, $token)
return new Response('', 404, array('Content-Type' => 'text/html'));
}

// the toolbar position (top, bottom, normal, or null -- use the configuration)
if (null === $position = $request->query->get('position')) {
$position = $this->toolbarPosition;
}

$url = null;
try {
$url = $this->generator->generate('_profiler', array('token' => $token));
Expand All @@ -175,7 +167,6 @@ public function toolbarAction(Request $request, $token)

return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', array(
'request' => $request,
'position' => $position,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getNames($profile),
'profiler_url' => $url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->booleanNode('toolbar')->defaultFalse()->end()
->scalarNode('position')
->defaultValue('bottom')
->setDeprecated('The "web_profiler.position" configuration key has been deprecated in Symfony 3.4 and it will be removed in 4.0.')
->validate()
->ifNotInArray(array('bottom', 'top'))
->thenInvalid('The CSS position %s is not supported')
->end()
->end()
->booleanNode('intercept_redirects')->defaultFalse()->end()
->scalarNode('excluded_ajax_paths')->defaultValue('^/(app(_[\\w]+)?\\.php/)?_wdt')->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ public function load(array $configs, ContainerBuilder $container)

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

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

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

$fileLinkFormatter = $container->getDefinition('debug.file_link_formatter');
$fileLinkFormatter->replaceArgument(2, $baseDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ class WebDebugToolbarListener implements EventSubscriberInterface
protected $urlGenerator;
protected $interceptRedirects;
protected $mode;
protected $position;
protected $excludedAjaxPaths;
private $cspHandler;

public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, $position = 'bottom', UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null)
public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null)
{
$this->twig = $twig;
$this->urlGenerator = $urlGenerator;
$this->interceptRedirects = (bool) $interceptRedirects;
$this->mode = (int) $mode;
$this->position = $position;
$this->excludedAjaxPaths = $excludedAjaxPaths;
$this->cspHandler = $cspHandler;
}
Expand Down Expand Up @@ -124,7 +122,6 @@ protected function injectToolbar(Response $response, Request $request, array $no
$toolbar = "\n".str_replace("\n", '', $this->twig->render(
'@WebProfiler/Profiler/toolbar_js.html.twig',
array(
'position' => $this->position,
'excluded_ajax_paths' => $this->excludedAjaxPaths,
'token' => $response->headers->get('X-Debug-Token'),
'request' => $request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<argument type="service" id="profiler" on-invalid="null" />
<argument type="service" id="twig" />
<argument>%data_collector.templates%</argument>
<argument>%web_profiler.debug_toolbar.position%</argument>
<argument type="service" id="web_profiler.csp.handler" />
<argument>null</argument>
</service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,5 @@
<xsd:complexType name="config">
<xsd:attribute name="toolbar" type="xsd:boolean" />
<xsd:attribute name="intercept-redirects" type="xsd:boolean" />
<xsd:attribute name="position" type="positions" />
</xsd:complexType>

<xsd:simpleType name="positions">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="top"/>
<xsd:enumeration value="bottom"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<argument type="service" id="twig" />
<argument>%web_profiler.debug_toolbar.intercept_redirects%</argument>
<argument>%web_profiler.debug_toolbar.mode%</argument>
<argument>%web_profiler.debug_toolbar.position%</argument>
<argument type="service" id="router" on-invalid="ignore" />
<argument /> <!-- paths that should be excluded from the AJAX requests shown in the toolbar -->
<argument type="service" id="web_profiler.csp.handler" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,34 +416,6 @@
display: none;
}

/* Override the setting when the toolbar is on the top */
{% if position == 'top' %}
.sf-minitoolbar {
border-bottom-left-radius: 4px;
border-top-left-radius: 0;
bottom: auto;
right: 0;
top: 0;
}

.sf-toolbarreset {
bottom: auto;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
top: 0;
}

.sf-toolbar-block .sf-toolbar-info {
bottom: auto;
top: 36px;
}
{% endif %}

{% if not floatable %}
.sf-toolbarreset {
position: static;
}
{% endif %}

/* Responsive Design */
.sf-toolbar-icon .sf-toolbar-label,
.sf-toolbar-icon .sf-toolbar-value {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
<div id="sfwdt{{ token }}" class="sf-toolbar sf-display-none"></div>
{{ include('@WebProfiler/Profiler/base_js.html.twig') }}
<style{% if csp_style_nonce %} nonce="{{ csp_style_nonce }}"{% endif %}>
{{ include('@WebProfiler/Profiler/toolbar.css.twig', { 'position': position, 'floatable': true }) }}
{{ include('@WebProfiler/Profiler/toolbar.css.twig') }}
</style>
<script{% if csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
(function () {
{% if 'top' == position %}
var sfwdt = document.getElementById('sfwdt{{ token }}');
document.body.insertBefore(
document.body.removeChild(sfwdt),
document.body.firstChild
);
{% endif %}

Sfjs.load(
'sfwdt{{ token }}',
'{{ path("_wdt", { "token": token }) }}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private function createController($profiler, $twig, $withCSP)
if ($withCSP) {
$nonceGenerator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock();

return new ProfilerController($urlGenerator, $profiler, $twig, array(), 'bottom', new ContentSecurityPolicyHandler($nonceGenerator));
return new ProfilerController($urlGenerator, $profiler, $twig, array(), new ContentSecurityPolicyHandler($nonceGenerator));
}

return new ProfilerController($urlGenerator, $profiler, $twig, array());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public function testConfigTree($options, $results)
public function getDebugModes()
{
return array(
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'top', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => 'test')),
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'excluded_ajax_paths' => 'test')),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function testXDebugUrlHeader()

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

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

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

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

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

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

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

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

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