11 public $stopOnEmpty = false;
13 public $cfgFiles = array();
14 public $cfgFileExists;
16 public function load()
18 $this->loadConfigFilePaths();
19 foreach ($this->cfgFiles as $file) {
20 if (file_exists($file)) {
21 $this->cfgFileExists = true;
22 return $this->loadFile($file);
25 $this->cfgFileExists = false;
28 protected function loadConfigFilePaths()
30 $pharFile = \Phar::running();
31 if ($pharFile == '') {
32 $this->cfgFiles[] = __DIR__ . '/../../data/bdrem.config.php';
34 //remove phar:// from the path
35 $this->cfgFiles[] = substr($pharFile, 7) . '.config.php';
38 //TODO: add ~/.config/bdrem.php
40 $this->cfgFiles[] = '/etc/bdrem.php';
43 protected function loadFile($filename)
46 $vars = get_defined_vars();
47 foreach ($vars as $k => $value) {
52 public function loadSource()
54 if ($this->source === null) {
55 throw new \Exception('No source defined');
58 $settings = $this->source;
59 $class = '\\bdrem\\Source_' . array_shift($settings);
61 return new $class($settings[0]);
64 public function setDate($date)
67 $this->date = date('Y-m-d');
69 $dt = new \DateTime($date);
70 $this->date = $dt->format('Y-m-d');
74 public function get($varname, $default = '')
76 if (!isset($this->$varname) || $this->$varname == '') {
79 return $this->$varname;