Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 3b42e75

Browse files
committed
Улучшен initializer.php, исправлены ошибки
1 parent adfd932 commit 3b42e75

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

assets/DebugBar/js/initializer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
var GDB = {
22

3-
};
3+
};
4+
5+
console.log(12345);

initializer.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Need include this file in init.php
44

55
use Bitrix\Main\Loader;
6+
use Bitrix\Main\Page\Asset;
67

78
$ggrachDebuggerRootPath = str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__);
89

@@ -26,14 +27,30 @@
2627
$ggrachDebuggerConfigurator->setLogPath('success', __DIR__ . '/logs/success.log');
2728
$ggrachDebuggerConfigurator->setLogPath('notice', __DIR__ . '/logs/notice.log');
2829

30+
global $GD;
31+
$GD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
32+
2933
/*
3034
* code - отображать дебаг-данные в коде
3135
* debug_bar - отображать дебаг-данные в debug_bar
3236
* log - отображать дебаг-данные в логе
3337
*/
34-
$ggrachDebuggerConfigurator->setShowModes(['code', 'debug_bar', 'log']);
35-
36-
global $GD;
37-
$GD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
38-
39-
include 'inizializer_alias.php';
38+
$GD->setShowModes(['code', 'debug_bar', 'log']);
39+
40+
global $USER;
41+
42+
if ($USER && $USER->IsAdmin()) {
43+
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
44+
Asset::getInstance()->addCss($ggrachDebuggerRootPath . "/assets/DebugBar/themes/${$ggrachDebugBarConfigurator->getColorTheme()}/fix.css");
45+
}
46+
47+
/**
48+
* Пример дебага:
49+
*
50+
* $GD->notice("Моя переменная', 'Моя переменная 2');
51+
* $GD->error('Моя переменная', 'Моя переменная 2');
52+
* $GD->warning('Моя переменная', 'Моя переменная 2');
53+
* $GD->success('Моя переменная', 'Моя переменная 2');
54+
*
55+
*/
56+
include 'inizializer_alias.php';

src/BitrixDebugger/Configurator/DebugBarConfigurator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class DebugBarConfigurator {
1515
* @var string
1616
*/
1717
protected $colorTheme = 'light';
18-
19-
public function getColorTheme(): type {
20-
return $this->theme;
18+
19+
public function getColorTheme(): string {
20+
return $this->colorTheme;
2121
}
2222

2323
public function setColorTheme(string $theme): void {
24-
$this->theme = $theme;
24+
$this->colorTheme = $theme;
2525
}
2626

2727
}

src/BitrixDebugger/Debugger/Debugger.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public function warning(...$item) {
7878
public function success(...$item) {
7979
$this->noticeRaw('success', $item);
8080
}
81+
82+
public function getLog(): array {
83+
return $this->log;
84+
}
8185

8286
/**
8387
* Кастомизированное уведомление

0 commit comments

Comments
 (0)