refactor shop collector

This commit is contained in:
Daniel Seifert 2025-03-24 10:44:03 +01:00
parent 6534af14c3
commit ce035a9742

View File

@ -20,28 +20,21 @@ use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable; use DebugBar\DataCollector\Renderable;
use Exception; use Exception;
use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Module\Module;
use OxidEsales\Eshop\Core\ShopVersion; use OxidEsales\Eshop\Core\ShopVersion;
use OxidEsales\Eshop\Core\Theme; use OxidEsales\Eshop\Core\Theme;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridge; use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridge;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridgeInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridgeInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
use OxidEsales\Facts\Facts; use OxidEsales\Facts\Facts;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
class OxidShopCollector extends DataCollector implements Renderable class OxidShopCollector extends DataCollector implements Renderable
{ {
/** @var Config */ protected Config $config;
protected $config;
/** @var array */ protected array $configVars = [];
protected $configVars = [];
/**
* @var bool
*/
protected $useHtmlVarDumper = true;
/** /**
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
@ -57,11 +50,11 @@ class OxidShopCollector extends DataCollector implements Renderable
$parentThemeId = $parent ? $parent->getId() : '--'; $parentThemeId = $parent ? $parent->getId() : '--';
$moduleList = $this->getInstalledModules(); $moduleList = $this->getInstalledModules();
$list = [];
array_walk( array_walk(
$moduleList, $moduleList,
function (Module &$module) { function (ModuleConfiguration $module) use (&$list) {
$str = trim(strip_tags($module->getTitle())).' - '.$module->getInfo('version').' '; $list[] = trim(strip_tags(current($module->getTitle()))).' - '.$module->getVersion();
$module = $str;
} }
); );
@ -71,8 +64,10 @@ class OxidShopCollector extends DataCollector implements Renderable
'CE Version:' => InstalledVersions::getVersion('oxid-esales/oxideshop-ce'), 'CE Version:' => InstalledVersions::getVersion('oxid-esales/oxideshop-ce'),
'Theme:' => $theme->getActiveThemeId(), 'Theme:' => $theme->getActiveThemeId(),
'Parent Theme:' => $parentThemeId, 'Parent Theme:' => $parentThemeId,
'Modules:' => implode(chr(10), $moduleList), 'Modules:' => $list,
]; ];
$this->useHtmlVarDumper(false);
} }
/** /**
@ -103,17 +98,6 @@ class OxidShopCollector extends DataCollector implements Renderable
return ['vars' => $data, 'count' => count($data)]; return ['vars' => $data, 'count' => count($data)];
} }
/**
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
* rendering.
*
* @return bool
*/
public function isHtmlVarDumperUsed(): bool
{
return $this->useHtmlVarDumper;
}
/** /**
* @return array * @return array
*/ */
@ -133,7 +117,7 @@ class OxidShopCollector extends DataCollector implements Renderable
} }
/** /**
* @return array * @return ModuleConfiguration[]
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
@ -147,13 +131,13 @@ class OxidShopCollector extends DataCollector implements Renderable
$modules = []; $modules = [];
foreach ($shopConfiguration->getModuleConfigurations() as $moduleConfiguration) { foreach ($shopConfiguration->getModuleConfigurations() as $moduleConfiguration) {
$module = oxNew(Module::class); $modules[] = $moduleConfiguration;
$module->load($moduleConfiguration->getId());
$modules[] = $module;
} }
/** @var $a ModuleConfiguration */
/** @var $b ModuleConfiguration */
usort($modules, function ($a, $b) { usort($modules, function ($a, $b) {
return strcmp($a->getTitle(), $b->getTitle()); return strcmp(current($a->getTitle()), current($b->getTitle()));
}); });
return $modules; return $modules;