diff --git a/admin/index.php b/admin/index.php
index 957fe1b6..2e0dcba8 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -30,6 +30,27 @@ if(!$db->hasTable('myaac_account_actions')) {
throw new RuntimeException('Seems that the table myaac_account_actions of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting this url.');
}
+$hooks->register('debugbar_admin_head_end', HOOK_ADMIN_HEAD_END, function ($params) {
+ global $debugBar;
+
+ if (!isset($debugBar)) {
+ return;
+ }
+
+ $debugBarRenderer = $debugBar->getJavascriptRenderer();
+ echo $debugBarRenderer->renderHead();
+});
+$hooks->register('debugbar_admin_body_end', HOOK_ADMIN_BODY_END, function ($params) {
+ global $debugBar;
+
+ if (!isset($debugBar)) {
+ return;
+ }
+
+ $debugBarRenderer = $debugBar->getJavascriptRenderer();
+ echo $debugBarRenderer->render();
+});
+
require SYSTEM . 'status.php';
require SYSTEM . 'login.php';
require __DIR__ . '/includes/functions.php';
diff --git a/composer.json b/composer.json
index ec34d395..0d227019 100644
--- a/composer.json
+++ b/composer.json
@@ -16,7 +16,8 @@
"peppeocchi/php-cron-scheduler": "4.*"
},
"require-dev": {
- "filp/whoops": "^2.15"
+ "filp/whoops": "^2.15",
+ "maximebf/debugbar": "dev-master"
},
"autoload": {
"psr-4": {
diff --git a/system/functions.php b/system/functions.php
index 13faf3d6..afa5e969 100644
--- a/system/functions.php
+++ b/system/functions.php
@@ -469,20 +469,30 @@ function tickers()
*/
function template_place_holder($type): string
{
- global $twig, $template_place_holders;
+ global $twig, $template_place_holders, $debugBar;
$ret = '';
+ if (isset($debugBar)) {
+ $debugBarRenderer = $debugBar->getJavascriptRenderer();
+ }
+
if(array_key_exists($type, $template_place_holders) && is_array($template_place_holders[$type]))
$ret = implode($template_place_holders[$type]);
if($type === 'head_start') {
$ret .= template_header();
+ if (isset($debugBar)) {
+ $ret .= $debugBarRenderer->renderHead();
+ }
}
elseif ($type === 'body_start') {
$ret .= $twig->render('browsehappy.html.twig');
}
elseif($type === 'body_end') {
$ret .= template_ga_code();
+ if (isset($debugBar)) {
+ $ret .= $debugBarRenderer->render();
+ }
}
return $ret;
diff --git a/system/init.php b/system/init.php
index 672e583e..f1ede3de 100644
--- a/system/init.php
+++ b/system/init.php
@@ -16,10 +16,16 @@ if(!isset($config['installed']) || !$config['installed']) {
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
}
+use DebugBar\StandardDebugBar;
+
if(config('env') === 'dev') {
require SYSTEM . 'exception.php';
}
+if (config('env') === 'dev' || getBoolean(config('enable_debugbar'))) {
+ $debugBar = new StandardDebugBar();
+}
+
if(empty($config['server_path'])) {
throw new RuntimeException('Server Path has been not set. Go to config.php and set it.');
}
diff --git a/system/libs/pot/OTS.php b/system/libs/pot/OTS.php
index d20d029c..9c988210 100644
--- a/system/libs/pot/OTS.php
+++ b/system/libs/pot/OTS.php
@@ -370,7 +370,14 @@ class POT
throw new RuntimeException('Please install PHP pdo extension. MyAAC will not work without it.');
}
- $this->db = new OTS_DB_MySQL($params);
+ global $debugBar;
+ if (isset($debugBar)) {
+ $this->db = new DebugBar\DataCollector\PDO\TraceablePDO(new OTS_DB_MySQL($params));
+ $debugBar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($this->db));
+ }
+ else {
+ $this->db = new OTS_DB_MySQL($params);
+ }
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}