'application/Espo/Resources/module.json', 'modulePath' => 'application/Espo/Modules/{*}/Resources/module.json', 'customPath' => 'custom/Espo/Custom/Resources/module.json', ]; public function __construct(FileManager $fileManager, bool $useCache = false) { $this->fileManager = $fileManager; $this->unifier = new FileUnifier($this->fileManager); $this->useCache = $useCache; } /** * Get module parameters. */ public function get($key = '', $returns = null) { if (!isset($this->data)) { $this->init(); } if (empty($key)) { return $this->data; } return Util::getValueByKey($this->data, $key, $returns); } /** * Get parameters of all modules. */ public function getAll() { return $this->get(); } protected function init() { if (file_exists($this->cacheFile) && $this->useCache) { $this->data = $this->fileManager->getPhpContents($this->cacheFile); return; } $this->data = $this->unifier->unify($this->paths, true); if ($this->useCache) { $result = $this->fileManager->putPhpContents($this->cacheFile, $this->data, false, true); if ($result === false) { throw new Error('Module: Could not save unified module data.'); } } } }