Browse Source

[WebProfilerBundle] Create a configuration panel

Victor Berchet 14 years ago
parent
commit
b04a647c65

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

@@ -30,10 +30,12 @@ class ProfilerController extends ContainerAware
      *
      * @return Response A Response instance
      */
-    public function panelAction($token, $panel = 'request')
+    public function panelAction($token)
     {
         $this->container->get('profiler')->disable();
 
+        $panel = $this->container->get('request')->query->get('panel', 'request');
+
         $profiler = $this->container->get('profiler')->loadFromToken($token);
 
         if ($profiler->isEmpty()) {

+ 0 - 3
src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml

@@ -28,7 +28,4 @@
         <default key="_controller">WebProfilerBundle:Profiler:panel</default>
     </route>
 
-    <route id="_profiler_panel" pattern="/{token}/{panel}">
-        <default key="_controller">WebProfilerBundle:Profiler:panel</default>
-    </route>
 </routes>

+ 3 - 3
src/Symfony/Bundle/WebProfilerBundle/Resources/public/css/profiler.css

@@ -198,9 +198,9 @@ fieldset
     background:#d1d1d1 url(../images/profiler/bg_submenu.gif) repeat-x 0 0;
 }
 
-.menu_profiler .request,
-.menu_profiler .request a,
-.menu_profiler .request a span.label
+.menu_profiler li:first-child,
+.menu_profiler li:first-child a,
+.menu_profiler li:first-child a span.label
 {
     -moz-border-radius:16px 0 0 0;
     -webkit-border-radius:16px 0 0 0;

BIN
src/Symfony/Bundle/WebProfilerBundle/Resources/public/images/profiler/config.png


+ 57 - 0
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig

@@ -34,3 +34,60 @@
     {% endset %}
     {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
 {% endblock %}
+
+{% block menu %}
+<span class="label">
+    <span class="icon"><img src="{{ asset('bundles/webprofiler/images/profiler/config.png') }}" alt="Configuration" /></span>
+    <strong>Config</strong>
+</span>
+{% endblock %}
+
+{% block panel %}
+    <h2>Configuration</h2>
+    <table>
+        <tr>
+            <th>Key</th>
+            <th>Value</th>
+        </tr>
+        <tr>
+            <th>Symfony version</th>
+            <td>{{ collector.symfonyversion }}</td>
+        </tr>
+        <tr>
+            <th>Application</th>
+            <td>{{ collector.appname }}</td>
+        </tr>
+        <tr>
+            <th>Environment</th>
+            <td>{{ collector.env }}</td>
+        </tr>
+        <tr>
+            <th>Debug</th>
+            <td>{{ collector.debug ? 'enabled' : 'disabled' }}</td>
+        </tr>
+        <tr>
+            <th>PHP version</th>
+            <td>{{ collector.phpversion }}</td>
+        </tr>
+        <tr>
+            <th>Xdebug</th>
+            <td>{{ collector.hasxdebug ? 'enabled' : 'disabled' }}</td>
+        </tr>
+        <tr>
+            <th>PHP acceleration</th>
+            <td>{{ collector.hasaccelerator ? 'enabled' : 'disabled' }}</td>
+        </tr>
+        <tr>
+            <th>XCache</th>
+            <td>{{ collector.hasxcache ? 'enabled' : 'disabled' }}</td>
+        </tr>
+        <tr>
+            <th>APC</th>
+            <td>{{ collector.hasapc ? 'enabled' : 'disabled' }}</td>
+        </tr>
+        <tr>
+            <th>EAccelerator</th>
+            <td>{{ collector.haseaccelerator ? 'enabled' : 'disabled' }}</td>
+        </tr>
+    </table>
+{% endblock %}

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

@@ -30,7 +30,7 @@
                                 {% set menu %}{{ template.renderBlock('menu', { 'collector': profiler.get(name)}) }}{% endset %}
                                 {% if menu != '' %}
                                     <li class="{{ name }}{% if name == panel %} selected{% endif %}">
-                                        <a href="{{ path('_profiler_panel', { 'token': token, 'panel': name }) }}">{{ menu|raw }}</a>
+                                        <a href="{{ path('_profiler', { 'token': token, 'panel': name }) }}">{{ menu|raw }}</a>
                                     </li>
                                 {% endif %}
                             {% endfor %}

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

@@ -1,10 +1,6 @@
 {% if link %}
     {% set icon %}
-        {% if 'config' == name %}
-            <a href="{{ path('_profiler', { 'token': token}) }}">{{ icon }}</a>
-        {% else %}
-            <a href="{{ path('_profiler_panel', { 'token': token, 'panel': name }) }}">{{ icon }}</a>
-        {% endif %}
+        <a href="{{ path('_profiler', { 'token': token, 'panel': name }) }}">{{ icon }}</a>
     {% endset %}
 {% endif %}
 {% if 'info' == status|default('info') %}

+ 38 - 12
src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php

@@ -48,14 +48,10 @@ class ConfigDataCollector extends DataCollector
             'env'             => $this->kernel->getEnvironment(),
             'debug'           => $this->kernel->isDebug(),
             'php_version'     => PHP_VERSION,
-            'xdebug'          => extension_loaded('xdebug'),
-            'accel'           => (
-                (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
-                ||
-                (extension_loaded('apc') && ini_get('apc.enabled'))
-                ||
-                (extension_loaded('xcache') && ini_get('xcache.cacher'))
-            ),
+            'xdebug_enabled'  => extension_loaded('xdebug'),
+            'eaccel_enabled'  => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'),
+            'apc_enabled'     => extension_loaded('apc') && ini_get('apc.enabled'),
+            'xcache_enabled'  => extension_loaded('xcache') && ini_get('xcache.cacher'),
         );
     }
 
@@ -126,17 +122,47 @@ class ConfigDataCollector extends DataCollector
      */
     public function hasXDebug()
     {
-        return $this->data['xdebug'];
+        return $this->data['xdebug_enabled'];
     }
 
     /**
-     * Returns true if an accelerator is enabled.
+     * Returns true if EAccelerator is enabled.
      *
-     * @return Boolean true if an accelerator is enabled, false otherwise
+     * @return Boolean true if EAccelerator is enabled, false otherwise
+     */
+    public function hasEAccelerator()
+    {
+        return $this->data['eaccel_enabled'];
+    }
+
+    /**
+     * Returns true if APC is enabled.
+     *
+     * @return Boolean true if APC is enabled, false otherwise
+     */
+    public function hasApc()
+    {
+        return $this->data['apc_enabled'];
+    }
+
+    /**
+     * Returns true if XCache is enabled.
+     *
+     * @return Boolean true if XCache is enabled, false otherwise
+     */
+    public function hasXCache()
+    {
+        return $this->data['xcache_enabled'];
+    }
+
+    /**
+     * Returns true if any accelerator is enabled.
+     *
+     * @return Boolean true if any accelerator is enabled, false otherwise
      */
     public function hasAccelerator()
     {
-        return $this->data['accel'];
+        return $this->hasApc() || $this->hasEAccelerator() || $this->hasXCache();
     }
 
     /**