Init debugBar

This commit is contained in:
slawkens 2023-08-10 13:05:02 +02:00
parent 7bab8f033c
commit cc7aec8e28
4 changed files with 38 additions and 2 deletions

View File

@ -35,6 +35,27 @@ require_once SYSTEM . 'hooks.php';
$hooks = new Hooks(); $hooks = new Hooks();
$hooks->load(); $hooks->load();
$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 . 'status.php';
require SYSTEM . 'login.php'; require SYSTEM . 'login.php';
require __DIR__ . '/includes/functions.php'; require __DIR__ . '/includes/functions.php';

View File

@ -14,6 +14,7 @@
"matomo/device-detector": "^6.0" "matomo/device-detector": "^6.0"
}, },
"require-dev": { "require-dev": {
"filp/whoops": "^2.15" "filp/whoops": "^2.15",
"maximebf/debugbar": "1.*"
} }
} }

View File

@ -457,20 +457,30 @@ function tickers()
*/ */
function template_place_holder($type): string function template_place_holder($type): string
{ {
global $twig, $template_place_holders; global $twig, $template_place_holders, $debugBar;
$ret = ''; $ret = '';
if (isset($debugBar)) {
$debugBarRenderer = $debugBar->getJavascriptRenderer();
}
if(array_key_exists($type, $template_place_holders) && is_array($template_place_holders[$type])) if(array_key_exists($type, $template_place_holders) && is_array($template_place_holders[$type]))
$ret = implode($template_place_holders[$type]); $ret = implode($template_place_holders[$type]);
if($type === 'head_start') { if($type === 'head_start') {
$ret .= template_header(); $ret .= template_header();
if (isset($debugBar)) {
$ret .= $debugBarRenderer->renderHead();
}
} }
elseif ($type === 'body_start') { elseif ($type === 'body_start') {
$ret .= $twig->render('browsehappy.html.twig'); $ret .= $twig->render('browsehappy.html.twig');
} }
elseif($type === 'body_end') { elseif($type === 'body_end') {
$ret .= template_ga_code(); $ret .= template_ga_code();
if (isset($debugBar)) {
$ret .= $debugBarRenderer->render();
}
} }
return $ret; return $ret;

View File

@ -13,8 +13,12 @@ if(!isset($config['installed']) || !$config['installed']) {
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.'); 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') { if(config('env') === 'dev') {
require SYSTEM . 'exception.php'; require SYSTEM . 'exception.php';
$debugBar = new StandardDebugBar();
} }
if(empty($config['server_path'])) { if(empty($config['server_path'])) {