2022-07-30 20:58:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace D3\DebugBar\Modules\Core;
|
|
|
|
|
|
|
|
use D3\DebugBar\Application\Component\DebugBarComponent;
|
2022-08-16 11:08:05 +02:00
|
|
|
use D3\DebugBar\Application\Models\DebugBarHandler;
|
2022-08-14 01:08:02 +02:00
|
|
|
use D3\DebugBar\Core\DebugBarExceptionHandler;
|
2022-08-16 11:08:05 +02:00
|
|
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
2022-07-30 20:58:10 +02:00
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2022-08-16 11:08:05 +02:00
|
|
|
use Throwable;
|
2022-07-30 20:58:10 +02:00
|
|
|
|
|
|
|
class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
|
|
|
{
|
2022-08-01 01:24:44 +02:00
|
|
|
public function __construct()
|
2022-07-30 20:58:10 +02:00
|
|
|
{
|
2022-08-16 11:08:05 +02:00
|
|
|
$handler = oxNew(DebugBarHandler::class);
|
|
|
|
|
|
|
|
$handler->setErrorHandler();
|
|
|
|
$handler->setExceptionHandler();
|
|
|
|
$handler->addDebugBarComponent();
|
2022-07-30 20:58:10 +02:00
|
|
|
|
2022-08-01 01:24:44 +02:00
|
|
|
parent::__construct();
|
2022-07-30 20:58:10 +02:00
|
|
|
}
|
|
|
|
|
2022-08-14 01:08:02 +02:00
|
|
|
/**
|
2022-08-16 11:08:05 +02:00
|
|
|
* @param string|null $controllerKey
|
|
|
|
* @param string|null $function
|
2022-08-16 11:08:53 +02:00
|
|
|
* @param array $parameters
|
|
|
|
* @param array $viewsChain
|
2022-08-14 01:08:02 +02:00
|
|
|
*/
|
2022-08-16 11:08:05 +02:00
|
|
|
public function start($controllerKey = null, $function = null, $parameters = null, $viewsChain = null)
|
2022-08-14 01:08:02 +02:00
|
|
|
{
|
2022-08-16 11:08:05 +02:00
|
|
|
parent::start();
|
2022-08-15 15:44:51 +02:00
|
|
|
|
2022-08-16 11:08:05 +02:00
|
|
|
global $debugBarSet, $debugBarErrorOccured;
|
2022-08-15 15:44:51 +02:00
|
|
|
|
2022-08-16 11:08:05 +02:00
|
|
|
if (!isAdmin() && $debugBarSet !== 1 && $debugBarErrorOccured !== 1) {
|
|
|
|
$activeView = Registry::getConfig()->getTopActiveView();
|
|
|
|
/** @var DebugBarComponent|null $debugBarComponent */
|
|
|
|
$debugBarComponent = $activeView->getComponent(DebugBarComponent::class);
|
|
|
|
if ($debugBarComponent) {
|
|
|
|
$debugBarSet = 1;
|
|
|
|
echo $debugBarComponent->getRenderer()->renderHead();
|
|
|
|
$debugBarComponent->addTimelineMessures();
|
|
|
|
echo $debugBarComponent->getRenderer()->render();
|
|
|
|
}
|
2022-08-15 15:44:51 +02:00
|
|
|
}
|
2022-08-14 01:08:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-08-16 11:08:05 +02:00
|
|
|
* @param Throwable $exception
|
2022-08-16 11:08:53 +02:00
|
|
|
* @return void
|
2022-08-14 01:08:02 +02:00
|
|
|
*/
|
2022-08-16 11:08:53 +02:00
|
|
|
protected function debugBarHandleException(Throwable $exception): void
|
2022-08-14 01:08:02 +02:00
|
|
|
{
|
2022-08-16 11:08:05 +02:00
|
|
|
$exceptionHandler = new DebugBarExceptionHandler();
|
|
|
|
$exceptionHandler->handleUncaughtException($exception);
|
2022-08-14 01:08:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-08-16 11:08:05 +02:00
|
|
|
* @param StandardException $exception
|
2022-08-14 01:08:02 +02:00
|
|
|
*/
|
2022-08-16 11:08:05 +02:00
|
|
|
protected function _handleSystemException($exception)
|
2022-08-14 01:08:02 +02:00
|
|
|
{
|
2022-08-16 11:08:05 +02:00
|
|
|
$this->debugBarHandleException($exception);
|
2022-08-14 01:08:02 +02:00
|
|
|
}
|
|
|
|
|
2022-07-30 20:58:10 +02:00
|
|
|
/**
|
2022-08-16 11:08:05 +02:00
|
|
|
* @param StandardException $exception
|
2022-07-30 20:58:10 +02:00
|
|
|
*/
|
2022-08-16 11:08:05 +02:00
|
|
|
protected function _handleCookieException($exception)
|
2022-07-30 20:58:10 +02:00
|
|
|
{
|
2022-08-16 11:08:05 +02:00
|
|
|
$this->debugBarHandleException($exception);
|
2022-07-30 20:58:10 +02:00
|
|
|
}
|
2022-08-01 01:24:44 +02:00
|
|
|
|
2022-08-15 15:44:51 +02:00
|
|
|
/**
|
2022-08-16 11:08:05 +02:00
|
|
|
* @param StandardException $exception
|
2022-08-15 15:44:51 +02:00
|
|
|
*/
|
2022-08-16 11:08:05 +02:00
|
|
|
protected function _handleBaseException($exception)
|
2022-08-01 01:24:44 +02:00
|
|
|
{
|
2022-08-16 11:08:05 +02:00
|
|
|
$this->debugBarHandleException($exception);
|
2022-08-01 01:24:44 +02:00
|
|
|
}
|
2022-08-01 22:27:28 +02:00
|
|
|
}
|