'application/Espo/Resources/module.json', 'modulePath' => 'application/Espo/Modules/{*}/Resources/module.json', 'customPath' => 'custom/Espo/Custom/Resources/module.json', ]; private $fileManager; private $dataCache; public function __construct(FileManager $fileManager, DataCache $dataCache, bool $useCache = false) { $this->fileManager = $fileManager; $this->dataCache = $dataCache; $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 ($this->dataCache->has($this->cacheKey) && $this->useCache) { $this->data = $this->dataCache->get($this->cacheKey); return; } $this->data = $this->unifier->unify($this->paths, true); if ($this->useCache) { $this->dataCache->store($this->cacheKey, $this->data); } } }