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

Commit c54951d

Browse files
committed
Keys modes debug relocate in constants
1 parent e1f9975 commit c54951d

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

ggrachdev.debugbar/classes/general/BitrixDebugger/Configurator/DebuggerConfigurator.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,57 +29,56 @@ class DebuggerConfigurator implements IShowModable {
2929
* @var string
3030
*/
3131
protected $logChunkDelimeter = "\n======\n";
32+
33+
public const SHOW_MODE_IN_CODE = 'code';
34+
public const SHOW_MODE_IN_DEBUG_BAR = 'debug_bar';
3235

3336
/**
34-
* Где показывать
37+
* Текущие режимы отображения
3538
*
3639
* code - в коде
3740
* debug_bar - в дебаг-баре
3841
*
3942
* @var array
4043
*/
41-
protected $showModes = ['code', 'debug_bar'];
44+
protected $showModes = [self::SHOW_MODE_IN_CODE, self::SHOW_MODE_IN_DEBUG_BAR];
4245

4346
public function getShowModes(): array {
4447
return $this->showModes;
4548
}
4649

4750
public function notShowDebugPanel() {
4851
$nowModes = $this->getShowModes();
49-
if (\in_array('debug_bar', $nowModes)) {
50-
unset($nowModes[\array_search('debug_bar', $nowModes)]);
52+
if (\in_array(self::SHOW_MODE_IN_DEBUG_BAR, $nowModes)) {
53+
unset($nowModes[\array_search(self::SHOW_MODE_IN_DEBUG_BAR, $nowModes)]);
5154
$this->setShowModes(\array_unique($nowModes));
5255
}
5356
return $this;
5457
}
5558

5659
public function notShowDebugInCode() {
5760
$nowModes = $this->getShowModes();
58-
if (\in_array('code', $nowModes)) {
59-
unset($nowModes[\array_search('code', $nowModes)]);
61+
if (\in_array(self::SHOW_MODE_IN_CODE, $nowModes)) {
62+
unset($nowModes[\array_search(self::SHOW_MODE_IN_CODE, $nowModes)]);
6063
$this->setShowModes(\array_unique($nowModes));
6164
}
6265
return $this;
6366
}
6467

6568
public function showDebugPanel() {
6669
$nowModes = $this->getShowModes();
67-
$nowModes[] = 'debug_bar';
70+
$nowModes[] = self::SHOW_MODE_IN_DEBUG_BAR;
6871
$this->setShowModes(\array_unique($nowModes));
6972
return $this;
7073
}
7174

7275
public function showDebugInCode() {
7376
$nowModes = $this->getShowModes();
74-
$nowModes[] = 'code';
77+
$nowModes[] = self::SHOW_MODE_IN_CODE;
7578
$this->setShowModes(\array_unique($nowModes));
7679
return $this;
7780
}
7881

79-
public function getShowModesEnum(): array {
80-
return ['code', 'debug_bar'];
81-
}
82-
8382
public function setShowModes(array $showModes): bool {
8483
$result = true;
8584

ggrachdev.debugbar/classes/general/BitrixDebugger/Validator/ShowModeDebuggerValidator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace GGrach\BitrixDebugger\Validator;
44

55
use GGrach\BitrixDebugger\Contract\IShowModable;
6+
use GGrach\BitrixDebugger\Configurator\DebuggerConfigurator;
67

78
/**
89
* Проверка допустимых действий для режимов отображения
@@ -12,12 +13,12 @@
1213
class ShowModeDebuggerValidator {
1314

1415
public static function needShowInDebugBar(IShowModable $showModable) {
15-
return in_array('debug_bar', $showModable->getShowModes());
16+
return in_array(DebuggerConfigurator::SHOW_MODE_IN_DEBUG_BAR, $showModable->getShowModes());
1617
}
1718

1819
public static function needShowInCode(IShowModable $showModable) {
1920
global $USER;
20-
return in_array('code', $showModable->getShowModes()) && \is_object($USER) && $USER->IsAdmin();
21+
return in_array(DebuggerConfigurator::SHOW_MODE_IN_CODE, $showModable->getShowModes()) && \is_object($USER) && $USER->IsAdmin();
2122
}
2223

2324
}

0 commit comments

Comments
 (0)