Skip to content

Commit 2686b83

Browse files
committed
refactor: improve Base_Profiler class
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent b14db3c commit 2686b83

1 file changed

Lines changed: 43 additions & 4 deletions

File tree

Core/libraries/Base_Profiler.php

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
class Base_Profiler extends \CI_Profiler
2727
{
2828

29+
30+
protected $_compile_;
31+
32+
protected $_ci_cached_vars;
33+
2934
protected $_available_sections = [
3035
'benchmarks',
3136
'get',
@@ -212,9 +217,9 @@ protected function _compile_eloquent()
212217
$output = [];
213218

214219
// hack to make eloquent not throw error for now
215-
// but checks if file actually exists, or CI will throw an error
216-
if (file_exists(filename: APPROOT . '/Models/Eloquent/Assets/Action.php')) {
217-
ci()->use->model('Eloquent/Assets/Action');
220+
// but checks if file actually exists, or WebbyPHP will throw an error
221+
if (file_exists(filename: APPROOT . '/Models/Eloquent/Action.php')) {
222+
ci()->use->model('Eloquent/Action');
218223
}
219224

220225
if (! class_exists('Illuminate\Database\Capsule\Manager', false)) {
@@ -228,7 +233,10 @@ protected function _compile_eloquent()
228233

229234

230235
$total = 0; // total query time
236+
shush();
231237
$queries = Illuminate\Database\Capsule\Manager::getQueryLog();
238+
speak_up();
239+
232240
foreach ($queries as $q) {
233241
$time = number_format($q['time'] / 1000, 4);
234242
$total += $q['time'] / 1000;
@@ -580,6 +588,37 @@ public function run()
580588
}
581589
}
582590

583-
return ci()->use->view('errors/profiling/profiler_template', ['sections' => $this->_sections], true);
591+
$profiler_view = 'errors/profiling/' . config_item('profiler_view') . PHPEXT ?: 'errors/profiling/' . 'default-view.php';
592+
593+
return ci()->use->view($profiler_view, [
594+
'sections' => $this->_sections,
595+
'config' => [
596+
'benchmarks' => true,
597+
'get' => true,
598+
'memory_usage' => true,
599+
'post' => true,
600+
'uri_string' => true,
601+
'controller_info' => true,
602+
'queries' => true,
603+
'eloquent' => true,
604+
'http_headers' => true,
605+
'config' => true,
606+
'files' => true,
607+
'console' => true,
608+
'userdata' => true,
609+
'view_data' => true,
610+
'session_data' => true
611+
],
612+
/**
613+
* The location of the profiler bar. Valid locations are:
614+
* bottom-left
615+
* bottom-right
616+
* top-left
617+
* top-right
618+
* bottom
619+
* top
620+
*/
621+
'profiler_bar_location' => config_item('profiler_bar_location') ?: 'bottom'
622+
], true);
584623
}
585624
}

0 commit comments

Comments
 (0)