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

Commit f7db2f9

Browse files
committed
Сделал initializer.php
1 parent f2a4fd1 commit f7db2f9

File tree

6 files changed

+54
-42
lines changed

6 files changed

+54
-42
lines changed

assets/DebugBar/js/initializer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var GDB = {
2+
3+
};

initializer.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@
44

55
use Bitrix\Main\Loader;
66

7-
include 'inizializer_alias.php';
8-
97
Loader::registerAutoLoadClasses(null, [
10-
"\Fred\GiftCard\Configuration\IblockConfiguration" => "/bitrix/php_interface/src/GiftCard/Configuration/IblockConfiguration.php",
11-
"\Fred\GiftCard\Configuration\OrderConfiguration" => "/bitrix/php_interface/src/GiftCard/Configuration/OrderConfiguration.php",
12-
"\Fred\GiftCard\Configuration\GiftCardConfiguration" => "/bitrix/php_interface/src/GiftCard/Configuration/GiftCardConfiguration.php",
13-
"\Fred\GiftCard\Configuration\SenderConfiguration" => "/bitrix/php_interface/src/GiftCard/Configuration/SenderConfiguration.php",
14-
"\Fred\GiftCard\Validation\GiftCardValidator" => "/bitrix/php_interface/src/GiftCard/Validation/GiftCardValidator.php",
15-
"\Fred\GiftCard\Repository\GiftCardsRepository" => "/bitrix/php_interface/src/GiftCard/Repository/GiftCardsRepository.php",
16-
"\Fred\GiftCard\Repository\GiftCardsSenderRepository" => "/bitrix/php_interface/src/GiftCard/Repository/GiftCardsSenderRepository.php",
17-
"\Fred\GiftCard\Order\GiftCardOrderManager" => "/bitrix/php_interface/src/GiftCard/Order/GiftCardOrderManager.php",
18-
"\Fred\GiftCard\Factory\GiftCardFactory" => "/bitrix/php_interface/src/GiftCard/Factory/GiftCardFactory.php",
19-
"\Fred\GiftCard\Factory\GiftCardQueueItemFactory" => "/bitrix/php_interface/src/GiftCard/Factory/GiftCardQueueItemFactory.php",
20-
"\Fred\GiftCard\Models\GiftCard" => "/bitrix/php_interface/src/GiftCard/Models/GiftCard.php",
21-
"\Fred\GiftCard\Models\GiftCardQueueItem" => "/bitrix/php_interface/src/GiftCard/Models/GiftCardQueueItem.php",
22-
"\Fred\GiftCard\Agents\GiftCardSendingAgent" => "/bitrix/php_interface/src/GiftCard/Agents/GiftCardSendingAgent.php",
23-
"\Fred\GiftCard\Utils\UserOrderCreatorUtil" => "/bitrix/php_interface/src/GiftCard/Utils/UserOrderCreatorUtil.php",
24-
"\Fred\GiftCard\Exception\CreateUserException" => "/bitrix/php_interface/src/GiftCard/Exception/CreateUserException.php",
25-
"\Fred\GiftCard\Senders\GiftCardsEmailSender" => "/bitrix/php_interface/src/GiftCard/Senders/GiftCardsEmailSender.php",
26-
"\Fred\GiftCard\Senders\GiftCardsSenderDistributor" => "/bitrix/php_interface/src/GiftCard/Senders/GiftCardsSenderDistributor.php",
27-
"\Fred\GiftCard\Senders\GiftCardsSmsSender" => "/bitrix/php_interface/src/GiftCard/Senders/GiftCardsSmsSender.php",
8+
"\GGrach\BitrixDebugger\Debugger\Debugger" => __DIR__ . "/src/BitrixDebugger/Debugger/Debugger.php",
9+
"\GGrach\BitrixDebugger\Debugger\DebuggerShowModable" => __DIR__ . "/src/BitrixDebugger/Debugger/DebuggerShowModable.php",
10+
"\GGrach\BitrixDebugger\Contract\ShowModableContract" => __DIR__ . "/src/BitrixDebugger/Contract/ShowModableContract.php",
11+
"\GGrach\BitrixDebugger\Configurator\DebuggerConfigurator" => __DIR__ . "/src/BitrixDebugger/Configurator/DebuggerConfigurator.php",
12+
"\GGrach\BitrixDebugger\Configurator\DebugBarConfigurator" => __DIR__ . "/src/BitrixDebugger/Configurator/DebugBarConfigurator.php",
13+
"\GGrach\BitrixDebugger\Cache\RuntimeCache" => __DIR__ . "/src/BitrixDebugger/Cache/RuntimeCache.php",
14+
"\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator" => __DIR__ . "/src/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
15+
"\GGrach\Writer\FileWriter" => __DIR__ . "/src/Writer/FileWriter.php",
16+
"\GGrach\Writer\Contract\WritableContract" => __DIR__ . "/src/Writer/Contract/WritableContract.php"
2817
]);
18+
19+
$ggrachDebuggerConfigurator = new \GGrach\BitrixDebugger\Configurator\DebuggerConfigurator();
20+
$ggrachDebugBarConfigurator = new \GGrach\BitrixDebugger\Configurator\DebugBarConfigurator();
21+
22+
$ggrachDebuggerConfigurator->setLogPath('error', __DIR__ . '/logs/error.log');
23+
$ggrachDebuggerConfigurator->setLogPath('warning', __DIR__ . '/logs/warning.log');
24+
$ggrachDebuggerConfigurator->setLogPath('success', __DIR__ . '/logs/success.log');
25+
$ggrachDebuggerConfigurator->setLogPath('notice', __DIR__ . '/logs/notice.log');
26+
27+
global $GD;
28+
$GD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
29+
30+
include 'inizializer_alias.php';

src/BitrixDebugger/Configurator/DebugBarConfigurator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
*
88
* @author ggrachdev
99
*/
10-
class DebuggerConfigurator {
10+
class DebugBarConfigurator {
1111

1212
/**
1313
* Цветовая схема дебаг-бара
1414
*
1515
* @var string
1616
*/
17-
protected $colorTheme = 'dark';
17+
protected $colorTheme = 'light';
1818

1919
public function getColorTheme(): type {
2020
return $this->theme;

src/BitrixDebugger/Configurator/DebuggerConfigurator.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ public function getLogPaths(): array {
5151
* @return string | null
5252
*/
5353
public function getLogPath(string $typeLog) {
54-
if(\array_key_exists($typeLog, $this->getLogPaths()))
55-
{
54+
if (\array_key_exists($typeLog, $this->getLogPaths())) {
5655
return $this->getLogPaths()[$typeLog];
57-
}
58-
else
59-
{
56+
} else {
6057
return null;
6158
}
6259
}

src/BitrixDebugger/Debugger/Debugger.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,36 +85,44 @@ public function debug($typeNotice, ...$item) {
8585
$this->noticeRaw($typeNotice, $item);
8686
}
8787

88-
protected function noticeRaw(string $type, $items) {
88+
protected function noticeRaw(string $type, $arLogItems) {
8989

9090
if (ShowModeDebuggerValidator::needShowInDebugBar($this)) {
91-
$this->log = array_merge($this->log, $items);
91+
$this->log = array_merge($this->log, $arLogItems);
9292
}
9393

9494
if (ShowModeDebuggerValidator::needShowInCode($this)) {
9595

9696
}
9797

98-
if (empty($items)) {
99-
return;
100-
}
101-
10298
if (ShowModeDebuggerValidator::needWriteInLog($this)) {
99+
100+
if (empty($arLogItems)) {
101+
return;
102+
}
103+
103104
$pathLogFile = $this->configuratorDebugger->getLogPath($type);
104105

105106
if ($pathLogFile) {
106107
$keyCache = $type . '_log_file_descriptor';
107108

108-
$fileLogResource = null;
109+
$fileLogDescriptor = null;
109110

110111
if (RuntimeCache::has($keyCache)) {
111-
$fileLogResource = RuntimeCache::get($keyCache);
112+
$fileLogDescriptor = RuntimeCache::get($keyCache);
112113
} else {
113-
$fileLogResource = \fopen($pathLogFile, 'w');
114-
RuntimeCache::set($keyCache, $fileLogResource);
114+
$fileLogDescriptor = \fopen($pathLogFile, 'a+');
115+
RuntimeCache::set($keyCache, $fileLogDescriptor);
116+
}
115117

116-
foreach ($items as $item) {
117-
FileWriter::write($item, $fileLogResource);
118+
if ($fileLogDescriptor) {
119+
foreach ($arLogItems as $logItem) {
120+
// @todo возможность вывести через var_dump, var_export
121+
FileWriter::write(
122+
print_r($logItem, true),
123+
$fileLogDescriptor,
124+
$this->configuratorDebugger->getLogChunkDelimeter()
125+
);
118126
}
119127
}
120128
}

src/Writer/FileWriter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FileWriter implements WritableContract {
1919
* @param string $delimeter
2020
*/
2121
public static function write(string $text, resource $resource, string $delimeter): bool {
22-
return fwrite($resource, $text.$delimeter) !== false;
22+
return fwrite($resource, $text . $delimeter) !== false;
2323
}
2424

2525
/**
@@ -28,9 +28,11 @@ public static function write(string $text, resource $resource, string $delimeter
2828
* @param resource $resource
2929
*/
3030
public static function clear(resource $resource): bool {
31-
$result = false;
3231

33-
return $result;
32+
$arMetaData = \stream_get_meta_data($resource);
33+
$pathFile = $arMetaData['uri'];
34+
35+
return \file_put_contents($pathFile, '');
3436
}
3537

3638
}

0 commit comments

Comments
 (0)