diff --git a/Application/Component/DebugBarComponent.php b/Application/Component/DebugBarComponent.php index 60e0c24..eafc4cb 100644 --- a/Application/Component/DebugBarComponent.php +++ b/Application/Component/DebugBarComponent.php @@ -141,6 +141,14 @@ class DebugBarComponent extends BaseController $property->setValue($this->debugBar, $collectors); } + /** + * @return StandardDebugBar + */ + public function getDebugBar(): StandardDebugBar + { + return $this->debugBar; + } + /** * @return JavascriptRenderer */ diff --git a/Modules/Core/ShopControl_DebugBar.php b/Modules/Core/ShopControl_DebugBar.php index 75b4ea6..f657fbd 100644 --- a/Modules/Core/ShopControl_DebugBar.php +++ b/Modules/Core/ShopControl_DebugBar.php @@ -50,7 +50,7 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent { if (!isAdmin()) { /** @var DebugBarComponent $debugBarComponent */ - $activeView = Registry::getConfig()->getActiveView(); + $activeView = Registry::getConfig()->getTopActiveView(); if ($activeView && $debugBarComponent = $activeView->getComponent(DebugBarComponent::class) ) { diff --git a/Modules/functions.php b/Modules/functions.php index e76d0c4..f85513a 100644 --- a/Modules/functions.php +++ b/Modules/functions.php @@ -13,7 +13,10 @@ declare(strict_types=1); +use D3\DebugBar\Application\Component\DebugBarComponent; use D3\DebugBar\Application\Models\TimeDataCollectorHandler; +use DebugBar\DataCollector\MessagesCollector; +use OxidEsales\Eshop\Core\Registry; function startProfile($sProfileName) { @@ -56,4 +59,28 @@ function stopProfile($sProfileName) } $executionCounts[$sProfileName]++; $aStartTimes[$sProfileName] = microtime(true); +} + +function debugVar($mVar, $blToFile = false) +{ + if ($blToFile) { + $out = var_export($mVar, true); + $f = fopen(Registry::getConfig()->getConfigParam('sCompileDir') . "/vardump.txt", "a"); + fwrite($f, $out); + fclose($f); + } else { + if (!isAdmin()) { + $activeView = Registry::getConfig()->getTopActiveView(); + /** @var DebugBarComponent $debugBarComponent */ + $debugBarComponent = $activeView->getComponent(DebugBarComponent::class); + /** @var MessagesCollector $messages */ + $messages = $debugBarComponent->getDebugBar()->getCollector('messages'); + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + //$location = $trace[1]['class'] . '::' . $trace[1]['function']. '(' . $trace[0]['line'] . ')'; + $location = $trace[1]['class'] . '::' . $trace[1]['function']; + $messages->addMessage($mVar, $location); + } else { + dumpVar($mVar, $blToFile); + } + } } \ No newline at end of file