Ejemplo n.º 1
0
 /**
  * Returns a key from the module configuration. If the value does not exist an exception will be thrown
  * @param string $var the key to retrieve
  * @param string $section the section of the config file to check. 
  * @param string $config the module file to check. Default is module (would check module.ini)
  * @return mixed
  */
 protected function getModuleVar($var, $section = null, $area = 'module')
 {
     if ($var == 'id' && $config == 'module') {
         KurogoDebug::Debug(func_get_args(), true);
     }
     if (!$this->configStore) {
         $this->initConfigStore();
     }
     return $this->configStore->getVar($var, $section, $area, $this);
 }
Ejemplo n.º 2
0
 public function saveConfig(Config $config)
 {
     $key = sprintf("%s-%s", $config->getType(), $config->getArea());
     if (!($file = $config->getFile('base'))) {
         throw new KurogoConfigurationException("Unable to load base file for " . $config->getType() . '-' . $config->getArea());
     }
     if (count($config->getFiles()) > 1) {
         KurogoDebug::Debug($config, true);
         throw new KurogoConfigurationException("Safety net. File will not be saved because it was loaded with extra files. The code is probably wrong");
     }
     $data = $config->getSaveData();
     if (!is_writable($file)) {
         throw new KurogoConfigurationException("Cannot save config file: {$file} Check permissions");
     }
     file_put_contents($file, $data);
     unset($this->configs[$key]);
     Kurogo::deleteCache('config-' . $key);
     return true;
 }