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

Commit 531cf0f

Browse files
committed
Update DebuggerConfigurator.php - add methods-helpers for debug mode
1 parent 15424a5 commit 531cf0f

1 file changed

Lines changed: 33 additions & 18 deletions

File tree

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

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,46 @@ public function getShowModes(): array {
4444
return $this->showModes;
4545
}
4646

47+
public function notShowDebugInPanel() {
48+
$nowModes = $this->getShowModes();
49+
if (\in_array('debug_bar', $nowModes)) {
50+
unset($nowModes[\array_search('debug_bar', $nowModes)]);
51+
$this->setShowModes(\array_unique($nowModes));
52+
}
53+
return $this;
54+
}
55+
56+
public function notShowDebugInCode() {
57+
$nowModes = $this->getShowModes();
58+
if (\in_array('code', $nowModes)) {
59+
unset($nowModes[\array_search('code', $nowModes)]);
60+
$this->setShowModes(\array_unique($nowModes));
61+
}
62+
return $this;
63+
}
64+
65+
public function showDebugInPanel() {
66+
$nowModes = $this->getShowModes();
67+
$nowModes[] = 'debug_bar';
68+
$this->setShowModes(\array_unique($nowModes));
69+
return $this;
70+
}
71+
72+
public function showDebugInCode() {
73+
$nowModes = $this->getShowModes();
74+
$nowModes[] = 'code';
75+
$this->setShowModes(\array_unique($nowModes));
76+
return $this;
77+
}
78+
4779
public function getShowModesEnum(): array {
4880
return ['code', 'debug_bar'];
4981
}
5082

5183
public function setShowModes(array $showModes): bool {
5284
$result = true;
5385

54-
if (!empty($showModes)) {
55-
56-
$avaliableModes = $this->getShowModesEnum();
57-
58-
// @todo array_udiff
59-
foreach ($showModes as $mode) {
60-
if (!\in_array($mode, $avaliableModes)) {
61-
$result = false;
62-
break;
63-
}
64-
}
65-
66-
if ($result) {
67-
$this->showModes = $showModes;
68-
}
69-
} else {
70-
$result = false;
71-
}
86+
$this->showModes = $showModes;
7287

7388
return $result;
7489
}

0 commit comments

Comments
 (0)