-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move DatabaseCollectorConfigurator from pomm-bundle
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
sources/lib/Configurator/DatabaseCollectorConfigurator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/* | ||
* This file is part of Pomm's SymfonyBidge package. | ||
* | ||
* (c) 2016 Grégoire HUBERT <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PommProject\SymfonyBridge\Configurator; | ||
|
||
use PommProject\Foundation\Pomm; | ||
use Symfony\Component\HttpKernel\DataCollector\DataCollector; | ||
|
||
/** | ||
* Data collector for the database profiler. | ||
* | ||
* @package PommSymfonyBridge | ||
* @copyright 2016 Grégoire HUBERT | ||
* @author Paris Mikael | ||
* @license X11 {@link http://opensource.org/licenses/mit-license.php} | ||
* @see DataCollector | ||
*/ | ||
class DatabaseCollectorConfigurator | ||
{ | ||
protected $datacollector; | ||
|
||
public function __construct(DataCollector $datacollector) | ||
{ | ||
$this->datacollector = $datacollector; | ||
} | ||
|
||
/** | ||
* @param Pomm $pomm | ||
* | ||
* @return null | ||
*/ | ||
public function configure(Pomm $pomm) | ||
{ | ||
$callable = [$this->datacollector, 'execute']; | ||
|
||
foreach ($pomm->getSessionBuilders() as $name => $builder) { | ||
$pomm->addPostConfiguration($name, function($session) use ($callable) { | ||
$session | ||
->getClientUsingPooler('listener', 'query') | ||
->attachAction($callable) | ||
; | ||
}); | ||
} | ||
} | ||
} |