/** * Set form options from directories * * @param array $dirs * @param string $form * @return void */ protected function _setFormOptionsFromDirs($dirs) { foreach ($dirs as $key => $value) { try { $file = $value . $this->_formConfigFile; $formOptions = new ZLayer_Config_File($file, APPLICATION_ENV); $options = $formOptions->process(); if ($options instanceof Zend_Config) { $this->_mergeOptions($options->toArray()); } } catch (ZLayer_Config_File_Exception $e) { } } }
/** * _makeFileOptions * * @param string $file * @param string $baseDir * @return array|bool */ private function _makeFileOptions($file, $baseDir) { $front = Zend_Controller_Front::getInstance(); $themeOptions = $front->getParam('bootstrap')->getPluginResource("theme")->getOptions(); // Set themes $themes = array($themeOptions["name"]); if (isset($themeOptions["parents"])) { $themes = array_merge_recursive($themes, $themeOptions["parents"]); } // Mount dirs $dirs = array(); $dirs[] .= APPLICATION_PATH . "/application/configs/" . $baseDir; foreach ($themeOptions["basePath"] as $key => $value) { foreach ($themes as $theme) { $dir = $value . $theme . "/configs/" . $baseDir; if (is_dir($dir)) { $dirs[] .= $dir; } } } try { $array = array(); foreach ($dirs as $dir) { $fileUri = $dir . $file; $fileObjConfig = new ZLayer_Config_File($fileUri, APPLICATION_ENV); $fileConfig = $fileObjConfig->process(); if ($fileConfig) { $array = array_merge_recursive($array, $fileConfig->toArray()); } } Zend_Registry::set($key, $array); return $array; } catch (ZLayer_Config_File_Exception $e) { } return null; }
/** * Load configuration file on directory * * @param string $dir Full path for configs file * @throws ZLayer_Config_Directory_Exception When directory is not exists * @return Zend_Config */ private function _loadConfigDir($dir) { // Scans directory if (is_dir($dir)) { $config = new Zend_Config(array(), true); $dir = new DirectoryIterator($dir); foreach ($dir as $entry) { if ($entry->isFile()) { try { $fileConfig = new ZLayer_Config_File($entry->getPathname(), $this->_section, true); $config->merge($fileConfig->process()); } catch (ZLayer_Config_File_Exception $e) { } } elseif ($entry->isDir() and !$entry->isDot() and $this->_recursive) { $config->merge($this->_loadConfigDir($entry->getPath())); } } return $config; } else { throw new ZLayer_Config_Directory_Exception('The directory ' . $dir . ' is not exists'); } }