{
$this->read_ini_file($this->spoolroot.'/configs/platal.ini');
$this->read_ini_file($this->spoolroot.'/configs/platal.conf');
- $this->read_ini_file($this->spoolroot.'/spool/conf/platal.dynamic.conf');
+ if (file_exists($this->spoolroot.'/spool/conf/platal.dynamic.conf')) {
+ $this->read_ini_file($this->spoolroot.'/spool/conf/platal.dynamic.conf');
+ }
}
-
+
/** Writes an ini file separated in categories
* @param filename the name of the file to write (overwrite existing)
* @param categories an array of categories (array of keys and values)
fwrite($f, '; vim:set syntax=dosini foldmethod=marker:'."\n");
fclose($f);
}
-
+
/** Change dynamic config file
* @param conf array of keys and values to add or replace
* @param category name of category to change
public function change_dynamic_config($conf, $category = 'Core')
{
$dynamicfile = $this->spoolroot.'/spool/conf/platal.dynamic.conf';
- $array = parse_ini_file($dynamicfile, true);
+ if (file_exists($dynamicfile)) {
+ $array = parse_ini_file($dynamicfile, true);
+ } else {
+ $array = null;
+ }
if (!is_array($array)) {
// dynamic conf is empty
$array = array($category => $conf);
$this->read_ini_file($dynamicfile);
}
+ public function bootstrap($conf, $callback, $category = 'Core')
+ {
+ $bootstrap = false;
+ $category = strtolower($category);
+ foreach ($conf as $key) {
+ if (!isset($this->$category->$key)) {
+ $bootstrap = true;
+ break;
+ }
+ }
+ if ($bootstrap) {
+ call_user_func($callback);
+ }
+ }
+
private function setlocale()
{
setlocale(LC_MESSAGES, $this->locale);