Skip to content

Commit

Permalink
Move DatabaseCollectorConfigurator from pomm-bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Nov 11, 2016
1 parent 2ba664d commit 375fa24
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions sources/lib/Configurator/DatabaseCollectorConfigurator.php
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)
;
});
}
}
}

0 comments on commit 375fa24

Please sign in to comment.