Browse Source

[WebProfileBundle] added the controller callable name in the WDT (also tweaked the CSS to free some space)

Fabien Potencier 14 years ago
parent
commit
20a717ea3c

File diff suppressed because it is too large
+ 1 - 1
src/Symfony/Bundle/DoctrineBundle/Resources/views/Collector/db.html.twig


File diff suppressed because it is too large
+ 1 - 1
src/Symfony/Bundle/DoctrineMongoDBBundle/Resources/views/Collector/mongodb.html.twig


+ 36 - 0
src/Symfony/Bundle/FrameworkBundle/DataCollector/RequestDataCollector.php

@@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\DataCollector;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector as BaseRequestDataCollector;
+use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
 
 /**
  * RequestDataCollector.
@@ -22,6 +23,13 @@ use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector as BaseReque
  */
 class RequestDataCollector extends BaseRequestDataCollector
 {
+    protected $controllers;
+
+    public function __construct()
+    {
+        $this->controllers = new \SplObjectStorage();
+    }
+
     /**
      * {@inheritdoc}
      */
@@ -30,6 +38,24 @@ class RequestDataCollector extends BaseRequestDataCollector
         parent::collect($request, $response, $exception);
 
         $this->data['route'] = $request->attributes->get('_route');
+        $this->data['controller'] = 'n/a';
+
+        if (isset($this->controllers[$request])) {
+            $controller = $this->controllers[$request];
+            if (is_array($controller)) {
+                $this->data['controller'] = array(get_class($controller[0]), $controller[1]);
+            } elseif ($controller instanceof \Closure) {
+                $this->data['controller'] = 'Closure';
+            } else {
+                $this->data['controller'] = (string) $controller ?: 'n/a';
+            }
+            unset($this->controllers[$request]);
+        }
+    }
+
+    public function onCoreController(FilterControllerEvent $event)
+    {
+        $this->controllers[$event->getRequest()] = $event->getController();
     }
 
     /**
@@ -41,4 +67,14 @@ class RequestDataCollector extends BaseRequestDataCollector
     {
         return $this->data['route'];
     }
+
+    /**
+     * Gets the controller.
+     *
+     * @return string The controller as a string
+     */
+    public function getController()
+    {
+        return $this->data['controller'];
+    }
 }

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml

@@ -21,6 +21,7 @@
         </service>
 
         <service id="data_collector.request" class="%data_collector.request.class%" public="false">
+            <tag name="kernel.listener" event="onCoreController" />
             <tag name="data_collector" template="WebProfilerBundle:Collector:request" id="request" priority="255" />
         </service>
 

File diff suppressed because it is too large
+ 1 - 1
src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig


File diff suppressed because it is too large
+ 23 - 17
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig


+ 1 - 1
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig

@@ -2,7 +2,7 @@
 
 {% block head %}
     <link href="{{ asset('bundles/framework/css/exception.css') }}" rel="stylesheet" type="text/css" media="screen" />
-    {{ parent() }}    
+    {{ parent() }}
 {% endblock %}
 
 {% block menu %}

File diff suppressed because it is too large
+ 1 - 1
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig


+ 1 - 1
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig

@@ -2,7 +2,7 @@
 
 {% block toolbar %}
     {% set icon %}
-        <img width="13" height="28" alt="Memory Usage" style="vertical-align: middle; margin-right: 10px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAcCAYAAAC6YTVCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJBJREFUeNpi/P//PwOpgImBDDAcNbE4ODiAg+/AgQOC586d+4BLoZGRkQBQ7Xt0mxQIWKCAzXkCBDQJDEBAIHOKiooicSkEBtTz0WQ0xFI5Mqevr285HrUOMAajvb09ySULk5+f3w1SNIDUMwKLsAIg256IrAECoEx6EKQJlLkkgJiDCE0/gPgF4+AuLAECDAAolCeEmdURAgAAAABJRU5ErkJggg=="/>
+        <img width="13" height="28" alt="Memory Usage" style="vertical-align: middle; margin-right: 5px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAcCAYAAAC6YTVCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJBJREFUeNpi/P//PwOpgImBDDAcNbE4ODiAg+/AgQOC586d+4BLoZGRkQBQ7Xt0mxQIWKCAzXkCBDQJDEBAIHOKiooicSkEBtTz0WQ0xFI5Mqevr285HrUOMAajvb09ySULk5+f3w1SNIDUMwKLsAIg256IrAECoEx6EKQJlLkkgJiDCE0/gPgF4+AuLAECDAAolCeEmdURAgAAAABJRU5ErkJggg=="/>
     {% endset %}
     {% set text %}
         {{ '%.0f'|format(collector.memory / 1024) }} KB

File diff suppressed because it is too large
+ 12 - 8
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig


File diff suppressed because it is too large
+ 1 - 1
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/timer.html.twig


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

@@ -3,7 +3,7 @@
         <a style="text-decoration: none; margin: 0; padding: 0;" href="{{ path('_profiler', { 'token': token, 'panel': name }) }}">{{ icon }}</a>
     {% endset %}
 {% endif %}
-<span style="white-space:nowrap; color:#2f2f2f; display:inline-block; min-height:24px; border-right:1px solid #cdcdcd; padding:5px 10px 5px 6px; ">
+<span style="white-space:nowrap; color:#2f2f2f; display:inline-block; min-height:24px; border-right:1px solid #cdcdcd; padding:5px 7px 5px 4px; ">
      {{ icon|default('') }}
      {{ text|default('') }}
 </span>