fix module

This commit is contained in:
Yuri Kuznetsov
2021-07-13 15:16:21 +03:00
parent 34b0402bc1
commit 81ff4f2c8a
+20 -7
View File
@@ -193,15 +193,28 @@ class Module
$data = [];
foreach ($this->getList() as $moduleName) {
$path = $this->getModulePath($moduleName) . '/' . $this->moduleFilePath;
$itemContents = $this->fileManager->getContents($path);
$data[$moduleName] = Json::decode($itemContents, true);
$data[$moduleName]['order'] = $data[$moduleName]['order'] ?? self::DEFAULT_ORDER;
$data[$moduleName] = $this->loadModuleData($moduleName);
}
return $data;
}
private function loadModuleData(string $moduleName): array
{
$path = $this->getModulePath($moduleName) . '/' . $this->moduleFilePath;
if (!$this->fileManager->exists($path)) {
return [
'order' => self::DEFAULT_ORDER,
];
}
$contents = $this->fileManager->getContents($path);
$data = Json::decode($contents, true);
$data['order'] = $data['order'] ?? self::DEFAULT_ORDER;
return $data;
}
}