[WebProfilerBundle] Add the posibility to specify position of toolbar
This commit is contained in:
parent
a74605532e
commit
69a50abcf8
@ -153,6 +153,7 @@ class ProfilerController extends ContainerAware
|
||||
|
||||
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:toolbar.html.twig', array(
|
||||
'position' => $position,
|
||||
'css_position' => $this->container->getParameter('web_profiler.debug_toolbar.css_position'),
|
||||
'profile' => $profile,
|
||||
'templates' => $this->getTemplates($profiler),
|
||||
'profiler_url' => $url,
|
||||
|
@ -38,6 +38,13 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->booleanNode('verbose')->defaultTrue()->end()
|
||||
->booleanNode('toolbar')->defaultFalse()->end()
|
||||
->scalarNode('css_position')
|
||||
->defaultValue('bottom')
|
||||
->validate()
|
||||
->ifNotInArray(array('bottom', 'top'))
|
||||
->thenInvalid('The CSS position %s is not supported')
|
||||
->end()
|
||||
->end()
|
||||
->booleanNode('intercept_redirects')->defaultFalse()->end()
|
||||
->end()
|
||||
;
|
||||
|
@ -54,7 +54,9 @@ class WebProfilerExtension extends Extension
|
||||
} else {
|
||||
$mode = WebDebugToolbarListener::ENABLED_MINIMAL;
|
||||
}
|
||||
|
||||
$container->setParameter('web_profiler.debug_toolbar.mode', $mode);
|
||||
$container->setParameter('web_profiler.debug_toolbar.css_position', $config['css_position']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,12 +37,14 @@ class WebDebugToolbarListener
|
||||
protected $templating;
|
||||
protected $interceptRedirects;
|
||||
protected $mode;
|
||||
protected $cssPosition;
|
||||
|
||||
public function __construct(TwigEngine $templating, $interceptRedirects = false, $mode = self::ENABLED)
|
||||
public function __construct(TwigEngine $templating, $interceptRedirects = false, $mode = self::ENABLED, $cssPosition = 'bottom')
|
||||
{
|
||||
$this->templating = $templating;
|
||||
$this->interceptRedirects = (Boolean) $interceptRedirects;
|
||||
$this->mode = (integer) $mode;
|
||||
$this->cssPosition = $cssPosition;
|
||||
}
|
||||
|
||||
public function isVerbose()
|
||||
@ -101,15 +103,27 @@ class WebDebugToolbarListener
|
||||
{
|
||||
if (function_exists('mb_stripos')) {
|
||||
$posrFunction = 'mb_strripos';
|
||||
$posFunction = 'mb_stripos';
|
||||
$substrFunction = 'mb_substr';
|
||||
} else {
|
||||
$posrFunction = 'strripos';
|
||||
$posFunction = 'stripos';
|
||||
$substrFunction = 'substr';
|
||||
}
|
||||
|
||||
$content = $response->getContent();
|
||||
|
||||
if (false !== $pos = $posrFunction($content, '</body>')) {
|
||||
$pos = $posrFunction($content, '</body>');
|
||||
|
||||
if ($this->cssPosition === 'bottom') {
|
||||
$pos = $posrFunction($content, '</body>');
|
||||
} else {
|
||||
$pos = $posFunction($content, '<body');
|
||||
if (false !== $pos) {
|
||||
$pos = $posFunction($content, '>', $pos) + 1;
|
||||
}
|
||||
}
|
||||
if (false !== $pos) {
|
||||
$toolbar = "\n".str_replace("\n", '', $this->templating->render(
|
||||
'WebProfilerBundle:Profiler:toolbar_js.html.twig',
|
||||
array('token' => $response->headers->get('X-Debug-Token'))
|
||||
|
@ -14,6 +14,7 @@
|
||||
<argument type="service" id="templating.engine.twig" />
|
||||
<argument>%web_profiler.debug_toolbar.intercept_redirects%</argument>
|
||||
<argument>%web_profiler.debug_toolbar.mode%</argument>
|
||||
<argument>%web_profiler.debug_toolbar.css_position%</argument>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -7,9 +7,15 @@
|
||||
{% if 'normal' != position %}
|
||||
style="position: {{ position }};
|
||||
background-color: #f7f7f7;
|
||||
{% if css_position == 'bottom' %}
|
||||
background-image: -moz-linear-gradient(-90deg, #e4e4e4, #ffffff);
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#e4e4e4), to(#ffffff));
|
||||
bottom: 0;
|
||||
{% else %}
|
||||
background-image: -moz-linear-gradient(-90deg, #ffffff, #e4e4e4);
|
||||
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ffffff), to(#e4e4e4));
|
||||
top: 0;
|
||||
{% endif %}
|
||||
left:0;
|
||||
margin:0;
|
||||
padding: 0;
|
||||
|
Reference in New Issue
Block a user