add OXID version informations

This commit is contained in:
Daniel Seifert 2022-08-04 16:03:32 +02:00 committed by Daniel Seifert
parent 870c57cefc
commit c1888bde70
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
5 changed files with 234 additions and 5 deletions

View File

@ -16,6 +16,8 @@ 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\OxidConfigCollector;
use D3\DebugBar\Application\Models\Collectors\OxidShopCollector;
use D3\DebugBar\Application\Models\Collectors\OxidVersionCollector;
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;
@ -102,6 +104,14 @@ class DebugBarComponent extends BaseController
return new SmartyCollector($smarty); return new SmartyCollector($smarty);
} }
/**
* @return OxidShopCollector
*/
public function getOxidShopCollector(): OxidShopCollector
{
return oxNew(OxidShopCollector::class);
}
/** /**
* @return OxidConfigCollector * @return OxidConfigCollector
*/ */
@ -110,6 +120,14 @@ class DebugBarComponent extends BaseController
return oxNew(OxidConfigCollector::class, Registry::getConfig()); return oxNew(OxidConfigCollector::class, Registry::getConfig());
} }
/**
* @return OxidVersionCollector
*/
public function getOxidVersionCollector(): OxidVersionCollector
{
return oxNew(OxidVersionCollector::class);
}
/** /**
* @param object $object * @param object $object
* @param string $propName * @param string $propName
@ -134,10 +152,12 @@ class DebugBarComponent extends BaseController
*/ */
public function addCollectors(StandardDebugBar $debugbar): void public function addCollectors(StandardDebugBar $debugbar): void
{ {
$debugbar->addCollector($this->getOxidShopCollector());
$debugbar->addCollector($this->getOxidConfigCollector());
$debugbar->addCollector($this->getSmartyCollector());
$debugbar->addCollector($this->getMonologCollector()); $debugbar->addCollector($this->getMonologCollector());
$debugbar->addCollector($this->getDoctrineCollector()); $debugbar->addCollector($this->getDoctrineCollector());
$debugbar->addCollector($this->getSmartyCollector()); $debugbar->addCollector($this->getOxidVersionCollector());
$debugbar->addCollector($this->getOxidConfigCollector());
} }
/** /**

View File

@ -128,7 +128,7 @@ class OxidConfigCollector extends DataCollector implements Renderable
: "PhpDebugBar.Widgets.VariableListWidget"; : "PhpDebugBar.Widgets.VariableListWidget";
return [ return [
"Configuration" => [ "Configuration" => [
"icon" => "tags", "icon" => "database",
"widget" => $widget, "widget" => $widget,
"map" => "oxidconfig.vars", "map" => "oxidconfig.vars",
"default" => "{}", "default" => "{}",

View File

@ -0,0 +1,143 @@
<?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 Composer\InstalledVersions;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Module\Module;
use OxidEsales\Eshop\Core\ShopVersion;
use OxidEsales\Eshop\Core\Theme;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridgeInterface;
use OxidEsales\Facts\Facts;
class OxidShopCollector extends DataCollector implements Renderable
{
/** @var Config */
protected $config;
/** @var array */
protected $configVars = [];
/**
* @var bool
*/
protected $useHtmlVarDumper = true;
public function __construct()
{
$facts = new Facts();
$theme = new Theme();
$parentThemeId = $theme->getParent() ? $theme->getParent()->getId() : '--';
$moduleList = $this->getInstalledModules();
array_walk(
$moduleList,
function (Module &$module) {
$str = trim(strip_tags($module->getTitle())).' - '.$module->getInfo('version').' ';
$module = $str;
}
);
$this->configVars = [
'Shop Edition:' => $facts->getEdition(),
'Shop Version:' => ShopVersion::getVersion(),
'CE Version:' => InstalledVersions::getVersion('oxid-esales/oxideshop-ce'),
'Theme:' => $theme->getActiveThemeId(),
'Parent Theme:' => $parentThemeId,
'Modules:' => implode(chr(10), $moduleList)
];
}
/**
* @return string
*/
public function getName(): string
{
return 'oxidshop';
}
/**
* @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 [
"Shop" => [
"icon" => "shopping-cart",
"widget" => $widget,
"map" => $this->getName().".vars",
"default" => "{}",
],
];
}
protected function getInstalledModules(): array
{
$container = ContainerFactory::getInstance()->getContainer();
$shopConfiguration = $container->get(ShopConfigurationDaoBridgeInterface::class)->get();
$modules = [];
foreach ($shopConfiguration->getModuleConfigurations() as $moduleConfiguration) {
$module = oxNew(Module::class);
$module->load($moduleConfiguration->getId());
$modules[] = $module;
}
usort($modules, function ($a, $b) {
return strcmp($a->getTitle(), $b->getTitle());
});
return $modules;
}
}

View File

@ -0,0 +1,66 @@
<?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\ShopVersion;
use OxidEsales\Eshop\Core\Theme;
use OxidEsales\Facts\Facts;
/**
* Collects info about OXID shop
*/
class OxidVersionCollector extends DataCollector implements Renderable
{
/**
* @return string
*/
public function getName()
{
return 'oxidversion';
}
/**
* @return array
*/
public function collect()
{
$facts = new Facts();
$theme = new Theme();
$parentThemeId = $theme->getParent() ? $theme->getParent()->getId() : '--';
return array(
'version' => $facts->getEdition().' '.ShopVersion::getVersion()
);
}
/**
* {@inheritDoc}
*/
public function getWidgets()
{
$collect = $this->collect();
return [
"oxidversion" => [
"icon" => "shopping-cart",
"tooltip" => 'OXID Version',
"map" => $this->getName().".version",
"default" => ""
],
];
}
}

View File

@ -101,12 +101,12 @@ class SmartyCollector extends DataCollector implements Renderable
: "PhpDebugBar.Widgets.VariableListWidget"; : "PhpDebugBar.Widgets.VariableListWidget";
return [ return [
"smarty" => [ "smarty" => [
"icon" => "tags", "icon" => "file-text",
"widget" => $widget, "widget" => $widget,
"map" => "smarty.vars", "map" => "smarty.vars",
"default" => "{}", "default" => "{}",
], ],
"smarty:badge" => [ "smarty:badge" => [
"map" => "smarty.count", "map" => "smarty.count",
"default" => 0, "default" => 0,
], ],