Skip to content

Commit

Permalink
- fix finding module extensions by module id
Browse files Browse the repository at this point in the history
  • Loading branch information
keywan-ghadami-oxid committed Jan 4, 2019
1 parent e49c55a commit 6183911
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Core/InternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,10 @@ public function checkModuleEvents()
*
* @return string
*/
public function getModuleNameSpace($sModulePath)
public function getModuleNameSpace()
{
$package = $this->getComposerPackage();

$sModulePath = $this->getModulePath();
if ($package) {
$autoload = $package->getAutoload();
} else {
Expand Down
41 changes: 30 additions & 11 deletions Core/ModuleExtensionCleanerDebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ public function setOutput(LoggerInterface $out){
*/
public function cleanExtensions($installedExtensions, \OxidEsales\Eshop\Core\Module\Module $module)
{
$installedExtensions = parent::cleanExtensions($installedExtensions, $module);
$moduleExtensions = $module->getExtensions();

$installedModuleExtensions = $this->filterExtensionsByModule($installedExtensions, $module);

if (count($installedModuleExtensions)) {
$garbage = $this->getModuleExtensionsGarbage($moduleExtensions, $installedModuleExtensions);

if (count($garbage)) {
$installedExtensions = $this->removeGarbage($installedExtensions, $garbage);
}
}

$oModules = oxNew( \OxidEsales\EshopCommunity\Core\Module\ModuleList::class );
//ids will include garbage in case there are files that not registered by any module
Expand Down Expand Up @@ -102,26 +112,35 @@ protected function getModuleExtensionsGarbage($moduleMetaDataExtensions, $module
* Returns extensions list by module id.
*
* @param array $modules Module array (nested format)
* @param string $moduleId Module id/folder name
* @param string $module Module id/folder name
*
* @return array
*/
protected function filterExtensionsByModuleId($modules, $moduleId)
protected function filterExtensionsByModule($modules, $module)
{
$modulePaths = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModulePaths');
if ($module->isMetadataVersionGreaterEqual('2.0')) {
$path = $module->getModuleNameSpace();
} else {

$modulePaths = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModulePaths');

$path = '';
if (isset($modulePaths[$moduleId])) {
$path = $modulePaths[$moduleId] . '/';
$moduleId = $module->getId();
$path = '';
if (isset($modulePaths[$moduleId])) {
$path = $modulePaths[$moduleId] . '/';
}

if (!$path) {
$path = $moduleId . "/";
}
}
$filteredModules = [];

// TODO: This condition should be removed. Need to check integration tests.
if (!$path) {
$path = $moduleId . "/";
return $filteredModules;
}

$filteredModules = [];
foreach ($modules as $class => $extend) {
foreach ($modules as $class => $extend) {
foreach ($extend as $extendPath) {
if (strpos($extendPath, $path) === 0) {
$filteredModules[$class][] = $extendPath;
Expand Down

0 comments on commit 6183911

Please sign in to comment.