Injected propel.connection in the PropelDataCollector collector

This commit is contained in:
William DURAND 2011-04-13 16:59:07 +02:00
parent 398c1b9566
commit 284dfeb355
2 changed files with 10 additions and 2 deletions

View file

@ -31,6 +31,12 @@ class PropelDataCollector extends DataCollector
* @var \PropelConfiguration * @var \PropelConfiguration
*/ */
protected $propelConfiguration; protected $propelConfiguration;
/**
* Propel connection
*
* @var \PropelPDO
*/
protected $propelConnection;
/** /**
* Constructor * Constructor
@ -38,11 +44,12 @@ class PropelDataCollector extends DataCollector
* @param \Propel\PropelBundle\Logger\PropelLogger $logger A PropelLogger * @param \Propel\PropelBundle\Logger\PropelLogger $logger A PropelLogger
* @param string $connectionName A connection name * @param string $connectionName A connection name
*/ */
public function __construct(\Propel\PropelBundle\Logger\PropelLogger $logger, $connectionName, \PropelConfiguration $propelConfiguration) public function __construct(\Propel\PropelBundle\Logger\PropelLogger $logger, $connectionName, \PropelConfiguration $propelConfiguration, \PropelPDO $propelConnection)
{ {
$this->logger = $logger; $this->logger = $logger;
$this->connectionName = $connectionName; $this->connectionName = $connectionName;
$this->propelConfiguration = $propelConfiguration; $this->propelConfiguration = $propelConfiguration;
$this->propelConnection = $propelConnection;
} }
/** /**
@ -53,7 +60,7 @@ class PropelDataCollector extends DataCollector
{ {
$this->data = array( $this->data = array(
'queries' => $this->buildQueries(), 'queries' => $this->buildQueries(),
'querycount' => \Propel::getConnection($this->connectionName)->getQueryCount(), 'querycount' => $this->propelConnection->getQueryCount(),
'connectionName' => $this->connectionName, 'connectionName' => $this->connectionName,
); );
} }

View file

@ -24,6 +24,7 @@
<argument type="service" id="propel.logger" /> <argument type="service" id="propel.logger" />
<argument>%propel.dbal.default_connection%</argument> <argument>%propel.dbal.default_connection%</argument>
<argument type="service" id="propel.configuration" /> <argument type="service" id="propel.configuration" />
<argument type="service" id="propel.connection" />
</service> </service>
</services> </services>
</container> </container>