Example #1
0
 public function config($name)
 {
     if (!empty($this->cconfig[$name])) {
         return $this->cconfig[$name];
     }
     $config = array();
     $file = $this->dir() . "/{$this->config_dir}/{$name}.php";
     if (is_file($file)) {
         $config = (array) Config_DSL::Builder()->load($file)->object;
     }
     $file = $this->dir() . "/{$this->user_config_dir}/{$name}.php";
     if (is_file($file)) {
         $user_data = Config_DSL::Builder()->load($file)->object;
         $config = Core_Arrays::deep_merge_update($config, (array) $user_data);
     }
     $result = (object) $config;
     $method = "config_{$name}";
     if (method_exists($this, $method)) {
         $result = $this->{$method}($result);
     }
     return $this->cconfig[$name] = $result;
 }
Example #2
0
 /**
  * Подгружает файл конфигурации в формате Config.DSL
  *
  * @param string $path
  *
  * @return CLI_Application_Base
  */
 protected function load_config($path)
 {
     if (IO_FS::exists($path)) {
         $this->log->debug('Using config: %s', $path);
         Config_DSL::Builder($this->config)->load($path);
     } else {
         throw new CLI_ApplicationException("Missing config file: {$path}");
     }
     return $this;
 }
Example #3
0
 public function read($path = null)
 {
     $path = !is_null($path) ? $path : $this->___path;
     if (!empty($path) && is_file($path)) {
         $obj = Config_DSL::Builder(new self())->load($path)->object;
         $this->extend($obj);
     }
     return $this;
 }