fileManager = $fileManager; $this->params = $params; } protected function getFileManager() { return $this->fileManager; } protected function getParams() { return $this->params; } /** * Unite file content to the file * * @param string $configParams - array('name', 'cachePath', 'corePath', 'customPath') * @param bool $recursively - Note: only for first level of sub directory, other levels of sub directories will be ignored * * @return array */ public function uniteFiles($configParams, $recursively=false) { //EXAMPLE OF IMPLEMENTATION IN METADATA CLASS /*if (empty($configParams) || empty($configParams['name']) || empty($configParams['cachePath']) || empty($configParams['corePath'])) { return false; } //merge matadata files $content= $this->uniteFilesSingle($configParams['corePath'], $configParams['name'], $recursively); if (!empty($configParams['customPath'])) { $customDir= strstr($configParams['customPath'], '{*}', true); $dirList= $this->getFileList($customDir, false, '', 'dir'); foreach($dirList as $dirName) { $curPath= str_replace('{*}', $dirName, $configParams['customPath']); //$content= array_merge($content, $this->uniteFilesSingle($curPath, $recursively)); $content= Utils\Util::merge($content, $this->uniteFilesSingle($curPath, $configParams['name'], $recursively)); } } //END: merge matadata files //save medatada to cache files $jsonData= $this->getObject('JSON')->encode($content); $cacheFile= Utils\Util::concatPath($configParams['cachePath'], $configParams['name']); $result= $this->putContents($cacheFile.'.json', $jsonData); $result&= $this->putContents($cacheFile.'.php', $this->getFileManager()->getPHPFormat($content)); //END: save medatada to cache files return $result; */ } /** * Unite file content to the file for one directory [NOW ONLY FOR METADATA, NEED TO CHECK FOR LAYOUTS AND OTHERS] * * @param string $dirPath * @param string $type - name of type array("metadata", "layouts"), ex. metadataConfig['name'] * @param bool $recursively - Note: only for first level of sub directory, other levels of sub directories will be ignored * @param string $moduleName - name of module if exists * * @return string - content of the files */ public function uniteFilesSingle($dirPath, $type, $recursively=false, $moduleName= '') { if (empty($dirPath) || !file_exists($dirPath)) { return false; } $params = $this->getParams(); $unsetFileName = $params['unsetFileName']; //$unsetFileName = $this->getConfig('unsetFileName'); //get matadata files $fileList = $this->getFileManager()->getFileList($dirPath, $recursively, '\.json$'); //print_r($fileList); //echo '