[DoctrineBundle] added connections and entity managers in web profiler

This commit is contained in:
Fabien Potencier 2011-05-01 10:06:10 +02:00
parent 422c7b2794
commit 74a243bdd6
3 changed files with 63 additions and 3 deletions

View File

@ -23,10 +23,14 @@ use Symfony\Bundle\DoctrineBundle\Logger\DbalLogger;
*/
class DoctrineDataCollector extends DataCollector
{
protected $logger;
private $connections;
private $managers;
private $logger;
public function __construct(DbalLogger $logger = null)
public function __construct($connections, $managers, DbalLogger $logger = null)
{
$this->connections = $connections;
$this->managers = $managers;
$this->logger = $logger;
}
@ -37,9 +41,21 @@ class DoctrineDataCollector extends DataCollector
{
$this->data = array(
'queries' => null !== $this->logger ? $this->logger->queries : array(),
'connections' => $this->connections,
'managers' => $this->managers,
);
}
public function getManagers()
{
return $this->data['managers'];
}
public function getConnections()
{
return $this->data['connections'];
}
public function getQueryCount()
{
return count($this->data['queries']);

View File

@ -26,6 +26,8 @@
<service id="data_collector.doctrine" class="%doctrine.data_collector.class%" public="false">
<tag name="data_collector" template="DoctrineBundle:Collector:db" id="db" />
<argument>%doctrine.dbal.connections%</argument>
<argument>%doctrine.orm.entity_managers%</argument>
<argument type="service" id="doctrine.dbal.logger" />
</service>

View File

@ -43,4 +43,46 @@
{% endfor %}
</ul>
{% endif %}
<h2>Database Connections</h2>
{% if collector.connections %}
<table>
<tr>
<th>Name</th>
<th>Service</th>
</tr>
{% for name, service in collector.connections %}
<tr>
<th>{{ name }}</th>
<td>{{ service }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>
<em>No entity managers.</em>
</p>
{% endif %}
<h2>Entity Managers</h2>
{% if collector.managers %}
<table>
<tr>
<th>Name</th>
<th>Service</th>
</tr>
{% for name, service in collector.managers %}
<tr>
<th>{{ name }}</th>
<td>{{ service }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>
<em>No entity managers.</em>
</p>
{% endif %}
{% endblock %}