Browse Source

merged vicb/profiler_verbose

Fabien Potencier 14 years ago
parent
commit
ae2629ce30

+ 1 - 0
src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

@@ -161,6 +161,7 @@ class ProfilerController extends ContainerAware
             'profiler'     => $profiler,
             'templates'    => $this->getTemplates($profiler),
             'profiler_url' => $url,
+            'verbose'      => $this->container->get('web_profiler.debug.toolbar')->getVerbose()
         ));
     }
 

+ 2 - 1
src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php

@@ -35,8 +35,9 @@ class Configuration
 
         $rootNode
             ->children()
+                ->booleanNode('verbose')->defaultTrue()->end()
                 ->booleanNode('toolbar')->defaultFalse()->end()
-                ->scalarNode('intercept_redirects')->defaultFalse()->end()
+                ->booleanNode('intercept_redirects')->defaultFalse()->end()
             ->end()
         ;
 

+ 4 - 1
src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php

@@ -47,7 +47,10 @@ class WebProfilerExtension extends Extension
             $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
             $loader->load('toolbar.xml');
 
-            $container->getDefinition('web_profiler.debug.toolbar')->setArgument(1, $config['intercept_redirects']);
+            $container->getDefinition('web_profiler.debug.toolbar')
+                ->setArgument(1, $config['intercept_redirects'])
+                ->setArgument(2, $config['verbose'])
+            ;
         }
     }
 

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

@@ -10,5 +10,6 @@
     <xsd:complexType name="config">
         <xsd:attribute name="toolbar" type="xsd:boolean" />
         <xsd:attribute name="intercept-redirects" type="xsd:boolean" />
+        <xsd:attribute name="verbose" type="xsd:boolean" />
     </xsd:complexType>
 </xsd:schema>

+ 1 - 0
src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml

@@ -13,6 +13,7 @@
             <tag name="kernel.listener" event="onCoreResponse" priority="-128" />
             <argument type="service" id="templating.engine.twig" />
             <argument /> <!-- intercept_redirects -->
+            <argument /> <!-- verbose -->
         </service>
     </services>
 </container>

+ 20 - 16
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig

@@ -6,16 +6,18 @@
     {% endset %}
     {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': false, 'text': collector.symfonyversion } %}
 
-    {% set text %}
-        {% spaceless %}
-            <span>PHP {{ collector.phpversion }}</span>
-            <span style="margin: 0; padding: 0; color: #979696;">|</span>
-            <span style="color: {{ collector.hasxdebug ? '#759e1a' : '#a33' }}">xdebug</span>
-            <span style="margin: 0; padding: 0; color: #979696">|</span>
-            <span style="color: {{ collector.hasaccelerator ? '#759e1a' : '#a33' }}">accel</span>
-        {% endspaceless %}
-    {% endset %}
-    {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': false, 'icon': '' } %}
+    {% if verbose %}
+        {% set text %}
+            {% spaceless %}
+                <span>PHP {{ collector.phpversion }}</span>
+                <span style="margin: 0; padding: 0; color: #979696;">|</span>
+                <span style="color: {{ collector.hasxdebug ? '#759e1a' : '#a33' }}">xdebug</span>
+                <span style="margin: 0; padding: 0; color: #979696">|</span>
+                <span style="color: {{ collector.hasaccelerator ? '#759e1a' : '#a33' }}">accel</span>
+            {% endspaceless %}
+        {% endset %}
+        {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': false, 'icon': '' } %}
+    {% endif %}
 
     {% set icon %}
         <img width="21" height="28" alt="Environment" style="border-width: 0; vertical-align: middle; margin-right: 5px;" src="data:image/png;base64,
@@ -23,12 +25,14 @@
     {% endset %}
     {% set text %}
         {% spaceless %}
-            <span>{{ collector.appname }}</span>
-            <span style="margin: 0; padding: 0; color: #979696;">|</span>
-            <span>{{ collector.env }}</span>
-            <span style="margin: 0; padding: 0; color: #979696;">|</span>
-            <span>{{ collector.debug ? 'debug' : 'no-debug' }}</span>
-            <span style="margin: 0; padding: 0; color: #979696;">|</span>
+            {% if verbose %}
+                <span>{{ collector.appname }}</span>
+                <span style="margin: 0; padding: 0; color: #979696;">|</span>
+                <span>{{ collector.env }}</span>
+                <span style="margin: 0; padding: 0; color: #979696;">|</span>
+                <span>{{ collector.debug ? 'debug' : 'no-debug' }}</span>
+                <span style="margin: 0; padding: 0; color: #979696;">|</span>
+            {% endif %}
             <span>
                 {% if profiler_url %}
                     <a style="color: #2f2f2f" href="{{ profiler_url }}">{{ collector.token }}</a>

+ 0 - 4
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

@@ -17,11 +17,7 @@
             <span style="margin: 0; padding: 0; color: #979696;">|</span>
             <span{{ not collector.route ? ' style="color:#a33"' : '' }}>{{ collector.route ? collector.route : 'NONE' }}</span>
             <span style="margin: 0; padding: 0; color: #979696;">|</span>
-            <span>{{ collector.format }}</span>
-            <span style="margin: 0; padding: 0; color: #979696;">|</span>
             <span style="color: {{ 200 == collector.statuscode ? '#759e1a' : '#a33' }}">{{ collector.statuscode }}</span>
-            <span style="margin: 0; padding: 0; color: #979696;">|</span>
-            <span>{{ collector.contenttype }}</span>
         {% endspaceless %}
     {% endset %}
     {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}

+ 8 - 1
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig

@@ -25,7 +25,14 @@
     <span style="display: inline-block; min-height: 24px; width: 40px; float: right;">&nbsp;</span>
 
     {% for name, template in templates %}
-        {{ template.renderblock('toolbar', { 'collector': profiler.get(name), 'profiler_url': profiler_url, 'token': profiler.token, 'name': name }) }}
+        {{ template.renderblock('toolbar', { 
+            'collector': profiler.get(name),
+            'profiler_url': profiler_url,
+            'token': profiler.token,
+            'name': name,
+            'verbose': verbose
+          })
+        }}
     {% endfor %}
 
     {% if 'normal' != position %}

+ 13 - 3
src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php

@@ -32,11 +32,18 @@ class WebDebugToolbarListener
 {
     protected $templating;
     protected $interceptRedirects;
+    protected $verbose;
 
-    public function __construct(TwigEngine $templating, $interceptRedirects = false)
+    public function __construct(TwigEngine $templating, $interceptRedirects = false, $verbose = true)
     {
         $this->templating = $templating;
-        $this->interceptRedirects = $interceptRedirects;
+        $this->interceptRedirects = (Boolean) $interceptRedirects;
+        $this->verbose = (Boolean) $verbose;
+    }
+
+    public function getVerbose()
+    {
+        return $this->verbose;
     }
 
     public function onCoreResponse(FilterResponseEvent $event)
@@ -91,7 +98,10 @@ class WebDebugToolbarListener
         $content = $response->getContent();
 
         if (false !== $pos = $posrFunction($content, '</body>')) {
-            $toolbar = "\n".str_replace("\n", '', $this->templating->render('WebProfilerBundle:Profiler:toolbar_js.html.twig', array('token' => $response->headers->get('X-Debug-Token'))))."\n";
+            $toolbar = "\n".str_replace("\n", '', $this->templating->render(
+                'WebProfilerBundle:Profiler:toolbar_js.html.twig',
+                array('token' => $response->headers->get('X-Debug-Token'))
+            ))."\n";
             $content = $substrFunction($content, 0, $pos).$toolbar.$substrFunction($content, $pos);
             $response->setContent($content);
         }