add OXID config vars tab
This commit is contained in:
parent
48ba33562e
commit
1f7306b436
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace D3\DebugBar\Application\Component;
|
namespace D3\DebugBar\Application\Component;
|
||||||
|
|
||||||
|
use D3\DebugBar\Application\Models\Collectors\OxidConfigCollector;
|
||||||
use D3\DebugBar\Application\Models\Collectors\SmartyCollector;
|
use D3\DebugBar\Application\Models\Collectors\SmartyCollector;
|
||||||
use D3\DebugBar\Application\Models\TimeDataCollectorHandler;
|
use D3\DebugBar\Application\Models\TimeDataCollectorHandler;
|
||||||
use DebugBar\Bridge\DoctrineCollector;
|
use DebugBar\Bridge\DoctrineCollector;
|
||||||
@ -101,6 +102,14 @@ class DebugBarComponent extends BaseController
|
|||||||
return new SmartyCollector($smarty);
|
return new SmartyCollector($smarty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return OxidConfigCollector
|
||||||
|
*/
|
||||||
|
public function getOxidConfigCollector(): OxidConfigCollector
|
||||||
|
{
|
||||||
|
return oxNew(OxidConfigCollector::class, Registry::getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $object
|
* @param object $object
|
||||||
* @param string $propName
|
* @param string $propName
|
||||||
@ -128,6 +137,7 @@ class DebugBarComponent extends BaseController
|
|||||||
$debugbar->addCollector($this->getMonologCollector());
|
$debugbar->addCollector($this->getMonologCollector());
|
||||||
$debugbar->addCollector($this->getDoctrineCollector());
|
$debugbar->addCollector($this->getDoctrineCollector());
|
||||||
$debugbar->addCollector($this->getSmartyCollector());
|
$debugbar->addCollector($this->getSmartyCollector());
|
||||||
|
$debugbar->addCollector($this->getOxidConfigCollector());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
142
Application/Models/Collectors/OxidConfigCollector.php
Normal file
142
Application/Models/Collectors/OxidConfigCollector.php
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<?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\Application\Models\Collectors;
|
||||||
|
|
||||||
|
use DebugBar\DataCollector\DataCollector;
|
||||||
|
use DebugBar\DataCollector\Renderable;
|
||||||
|
use OxidEsales\Eshop\Core\Config;
|
||||||
|
use OxidEsales\Eshop\Core\ConfigFile;
|
||||||
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
use ReflectionClass;
|
||||||
|
use ReflectionException;
|
||||||
|
|
||||||
|
class OxidConfigCollector extends DataCollector implements Renderable
|
||||||
|
{
|
||||||
|
/** @var Config */
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $configVars = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $useHtmlVarDumper = false;
|
||||||
|
|
||||||
|
public function __construct(Config $config)
|
||||||
|
{
|
||||||
|
$config->init();
|
||||||
|
$this->config = $config;
|
||||||
|
$this->configVars = array_merge(
|
||||||
|
(array) $this->getNonPublicProperty($this->config, '_aConfigParams'),
|
||||||
|
Registry::get(ConfigFile::class)->getVars()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->sanitizeCriticalProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function sanitizeCriticalProperties(): void
|
||||||
|
{
|
||||||
|
$generic = (array) preg_grep('/Password/', array_keys($this->configVars));
|
||||||
|
$specific = ['sSerialNr', 'aSerials', 'dbPwd'];
|
||||||
|
$search = array_merge($generic, $specific);
|
||||||
|
|
||||||
|
array_walk($this->configVars, function ($item, $key) use ($search) {
|
||||||
|
if (in_array($key, $search)) {
|
||||||
|
$this->configVars[$key] = '[hidden]';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param object $object
|
||||||
|
* @param string $propName
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
protected function getNonPublicProperty(object $object, string $propName)
|
||||||
|
{
|
||||||
|
$reflection = new ReflectionClass($object);
|
||||||
|
$property = $reflection->getProperty($propName);
|
||||||
|
$property->setAccessible(true);
|
||||||
|
return $property->getValue($object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return 'oxidconfig';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function collect(): array
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
$vars = $this->configVars;
|
||||||
|
|
||||||
|
foreach ($vars as $idx => $var) {
|
||||||
|
if ($this->isHtmlVarDumperUsed()) {
|
||||||
|
$data[$idx] = $this->getVarDumper()->renderVar($var);
|
||||||
|
} else {
|
||||||
|
$data[$idx] = $this->getDataFormatter()->formatVar($var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['vars' => $data, 'count' => count($data)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
|
||||||
|
* rendering.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function isHtmlVarDumperUsed()
|
||||||
|
{
|
||||||
|
return $this->useHtmlVarDumper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getWidgets(): array
|
||||||
|
{
|
||||||
|
$widget = $this->isHtmlVarDumperUsed()
|
||||||
|
? "PhpDebugBar.Widgets.HtmlVariableListWidget"
|
||||||
|
: "PhpDebugBar.Widgets.VariableListWidget";
|
||||||
|
return [
|
||||||
|
"Configuration" => [
|
||||||
|
"icon" => "tags",
|
||||||
|
"widget" => $widget,
|
||||||
|
"map" => "oxidconfig.vars",
|
||||||
|
"default" => "{}",
|
||||||
|
],
|
||||||
|
"Configuration:badge" => [
|
||||||
|
"map" => "oxidconfig.count",
|
||||||
|
"default" => 0,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -14,4 +14,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Doctrine database queries collector
|
- Doctrine database queries collector
|
||||||
- Smarty variables collector
|
- Smarty variables collector
|
||||||
- Timeline profiling collector
|
- Timeline profiling collector
|
||||||
|
- Shop configuration collector
|
||||||
- Collector for freely definable debug messages
|
- Collector for freely definable debug messages
|
18
README.en.md
18
README.en.md
@ -46,6 +46,24 @@ If necessary, please confirm that you allow `composer-symlinker` to execute code
|
|||||||
|
|
||||||
Activate the module in Shopadmin under "Extensions -> Modules".
|
Activate the module in Shopadmin under "Extensions -> Modules".
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
The DebugBar displays the following tabs:
|
||||||
|
- Messages
|
||||||
|
can contain individual debug output. Messages can be set within the PHP code with `debugVar($message)` and corresponds to the OXID function `dumpVar(...)`
|
||||||
|
- Request
|
||||||
|
shows all information from GET and POST requests, as well as session, cookie and server variables
|
||||||
|
- Timeline
|
||||||
|
displays all areas defined with `startProfile` and `stopProfile` with single and summed execution time as well as a waterfall diagram
|
||||||
|
- Monolog
|
||||||
|
lists all log messages passed to the Monolog Logger
|
||||||
|
- Database
|
||||||
|
shows all database queries necessary to generate the current page
|
||||||
|
- Smarty
|
||||||
|
lists all Smarty variables available on the current shop page
|
||||||
|
- Configuration
|
||||||
|
Provides all configuration settings of the shop (from database and file).
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
See [CHANGELOG](CHANGELOG.md) for further informations.
|
See [CHANGELOG](CHANGELOG.md) for further informations.
|
||||||
|
@ -46,9 +46,6 @@ Sofern nötig, bestätigen Sie bitte, dass Sie `composer-symlinker` erlauben, Co
|
|||||||
|
|
||||||
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
||||||
|
|
||||||
```
|
|
||||||
include './modules/d3/debugbar/Modules/functions.php';
|
|
||||||
```
|
|
||||||
## Verwendung
|
## Verwendung
|
||||||
|
|
||||||
Die DebugBar stellt folgende Tabs dar:
|
Die DebugBar stellt folgende Tabs dar:
|
||||||
@ -64,6 +61,8 @@ Die DebugBar stellt folgende Tabs dar:
|
|||||||
zeigt alle zur Generierung der aktuellen Seite nötigen Datenbankabfragen
|
zeigt alle zur Generierung der aktuellen Seite nötigen Datenbankabfragen
|
||||||
- Smarty
|
- Smarty
|
||||||
listet alle Smarty-Variablen, die auf der aktuellen Shopseite zur Verfügung stehen
|
listet alle Smarty-Variablen, die auf der aktuellen Shopseite zur Verfügung stehen
|
||||||
|
- Configuration
|
||||||
|
stellt alle Konfigurationseinstellungen des Shops aus Datenbank und Dateien zur Verfügung
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user