Added proper providers to handle registration and boot.

This commit is contained in:
Andrey Savchenko committed 2018-02-13 11:37:54 +02:00
1 parent 48b3383e06
commit 06e3bb4657
10 files changed
+95 -97

No files matched your search

+3 -11
View File
@@ -2,29 +2,21 @@
namespace Rarst\Laps\Record;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Bootable_Provider_Interface;
use Rarst\Laps\Events\Core_Events;
use Rarst\Laps\Events\Laps_Events;
use Rarst\Laps\Laps;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Stopwatch\StopwatchEvent;
class Hook_Record_Collector implements ServiceProviderInterface, Bootable_Provider_Interface, Record_Collector_Interface {
class Hook_Record_Collector implements Record_Collector_Interface {
/** @var Stopwatch $stopwatch */
protected $stopwatch;
protected $events = [];
public function register( Container $pimple ) {
public function __construct( Stopwatch $stopwatch ) {
}
public function boot( Laps $laps ) {
$this->stopwatch = $laps['stopwatch'];
$this->stopwatch = $stopwatch;
$this->stopwatch->start( 'Plugins Load', 'plugin' );
+3 -11
View File
@@ -2,25 +2,17 @@
namespace Rarst\Laps\Record;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Bootable_Provider_Interface;
use Rarst\Laps\Laps;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Stopwatch\StopwatchEvent;
class Http_Record_Collector implements ServiceProviderInterface, Bootable_Provider_Interface, Record_Collector_Interface {
class Http_Record_Collector implements Record_Collector_Interface {
/** @var Stopwatch $stopwatch */
protected $stopwatch;
public function register( Container $pimple ) {
public function __construct( Stopwatch $stopwatch ) {
}
public function boot( Laps $laps ) {
$this->stopwatch = $laps['stopwatch'];
$this->stopwatch = $stopwatch;
add_action( 'pre_http_request', [ $this, 'pre_http_request' ], 10, 3 );
add_action( 'http_api_debug', [ $this, 'http_api_debug' ], 10, 5 );
+2 -11
View File
@@ -2,20 +2,11 @@
namespace Rarst\Laps\Record;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Bootable_Provider_Interface;
use Rarst\Laps\Laps;
class Sql_Record_Collector implements ServiceProviderInterface, Bootable_Provider_Interface, Record_Collector_Interface {
class Sql_Record_Collector implements Record_Collector_Interface {
protected $query_starts = [];
public function register( Container $pimple ) {
}
public function boot( Laps $laps ) {
public function __construct() {
if ( $this->is_savequeries() ) {
add_filter( 'query', [ $this, 'query' ], 20 );