From e80ab5ee59cf3761b649c67ef43530787eb9f2cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Visti=20Kl=C3=B8ft?=
Date: Tue, 8 Nov 2016 23:16:58 +0100
Subject: [PATCH] can public config file
---
src/PerformanceServiceProvider.php | 11 +++++++++--
src/QueryContainer.php | 2 +-
src/ressources/performance.php | 5 +++++
3 files changed, 15 insertions(+), 3 deletions(-)
create mode 100644 src/ressources/performance.php
diff --git a/src/PerformanceServiceProvider.php b/src/PerformanceServiceProvider.php
index b1da0b3..6baf86f 100644
--- a/src/PerformanceServiceProvider.php
+++ b/src/PerformanceServiceProvider.php
@@ -11,14 +11,21 @@
class PerformanceServiceProvider extends ServiceProvider
{
public function boot()
+ {
+ $this->publishes([
+ __DIR__ . '/ressources/performance.php' => config_path('performance.php'),
+ ]);
+ }
+
+ public function register()
{
$dispatcher = $this->app->make(Dispatcher::class);
- $this->app->singleton(QueryContainer::class, function($app) {
+ $this->app->singleton(QueryContainer::class, function ($app) {
return new QueryContainer($app->make(Request::class), $app->make(Filesystem::class));
});
- $dispatcher->listen(QueryExecuted::class, function(QueryExecuted $event) {
+ $dispatcher->listen(QueryExecuted::class, function (QueryExecuted $event) {
$container = $this->app->make(QueryContainer::class);
$container->addByEvent($event);
});
diff --git a/src/QueryContainer.php b/src/QueryContainer.php
index e79962a..b3e13c0 100644
--- a/src/QueryContainer.php
+++ b/src/QueryContainer.php
@@ -41,7 +41,7 @@ class QueryContainer
public function __construct(Request $request = null, Filesystem $filesystem)
{
$this->resetCounters();
- $this->slowQueryThreshold = 10;
+ $this->slowQueryThreshold = config('performance.slow_query_threshold', 100);
$this->timestamp = Carbon::now();
$this->url = $request->getPathInfo();
$this->method = $request->getMethod();
diff --git a/src/ressources/performance.php b/src/ressources/performance.php
new file mode 100644
index 0000000..ecc1c0e
--- /dev/null
+++ b/src/ressources/performance.php
@@ -0,0 +1,5 @@
+ 10
+];
\ No newline at end of file