From c93249875b57b5a8ffec94fb418219e73bca2c1d Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Thu, 8 Feb 2018 16:20:30 +0200 Subject: [PATCH] Changed Stopwatch service to a factory. --- src/Events/Http_Events_Provider.php | 7 ++++++- src/Laps.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Events/Http_Events_Provider.php b/src/Events/Http_Events_Provider.php index 404841f..be5c7f2 100644 --- a/src/Events/Http_Events_Provider.php +++ b/src/Events/Http_Events_Provider.php @@ -8,7 +8,7 @@ use Rarst\Laps\Bootable_Provider_Interface; use Rarst\Laps\Laps; use Symfony\Component\Stopwatch\Stopwatch; -class Http_Events_Provider implements ServiceProviderInterface, Bootable_Provider_Interface { +class Http_Events_Provider implements ServiceProviderInterface, Bootable_Provider_Interface, Events_Provider_Interface { /** @var Stopwatch $stopwatch */ protected $stopwatch; @@ -58,4 +58,9 @@ class Http_Events_Provider implements ServiceProviderInterface, Bootable_Provide return $response; } + + public function get_events() { + + return $this->stopwatch->getSectionEvents( '__root__' ); + } } \ No newline at end of file diff --git a/src/Laps.php b/src/Laps.php index f4121e2..c8c3d09 100644 --- a/src/Laps.php +++ b/src/Laps.php @@ -31,9 +31,9 @@ class Laps extends Container { ] ); }; - $laps['stopwatch'] = function () { + $laps['stopwatch'] = $laps->factory( function () { return new Stopwatch(); - }; + } ); $laps->register( new Hook_Events_Provider() ); $laps->register( new Http_Events_Provider() );