Permalink
Browse files

Register an event handler triggered sooner.

  • Loading branch information...
1 parent 93c88d4 commit 55b46507a13d9ab4ff1a51c1c0cdd1aa9a024515 @johannes committed Oct 2, 2011
Showing with 10 additions and 1 deletion.
  1. +8 −0 DataCollector/MysqlndDataCollector.php
  2. +2 −1 Resources/config/services.xml
@@ -5,6 +5,7 @@
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* Data collector collecting mysqlnd statistics.
@@ -22,6 +23,13 @@ public function __construct()
}
}
+ public function onEarlyKernelRequest(GetResponseEvent $event)
+ {
+ if (!$this->initialData && function_exists('mysqli_get_client_stats')) {
+ $this->initialData = mysqli_get_client_stats();
+ }
+ }
+
/**
* {@inheritdoc}
*/
@@ -9,8 +9,9 @@
</parameters>
<services>
- <service id="data_collector.mysqlnd" class="%js_mysqlnd.data_collector.class%" public="false">
+ <service id="data_collector.mysqlnd" class="%js_mysqlnd.data_collector.class%" public="true">
<tag name="data_collector" template="JSMysqlndBundle:Collector:mysqlnd" id="mysqlnd" />
+ <tag name="kernel.event_listener" event="kernel.request" method="onEarlyKernelRequest" />
</service>
</services>

0 comments on commit 55b4650

Please sign in to comment.