From 81ff4f2c8a3d3b137444a8024a4277e9aac0fb50 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 13 Jul 2021 15:16:21 +0300 Subject: [PATCH] fix module --- application/Espo/Core/Utils/Module.php | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/application/Espo/Core/Utils/Module.php b/application/Espo/Core/Utils/Module.php index 75d11619a4..5cce830d38 100644 --- a/application/Espo/Core/Utils/Module.php +++ b/application/Espo/Core/Utils/Module.php @@ -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; + } }