aboutsummaryrefslogtreecommitdiff
path: root/src/bdrem/Config.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2014-02-25 07:47:24 +0100
committerChristian Weiske <cweiske@cweiske.de>2014-02-25 07:47:24 +0100
commit5f35a084b38723da7b505bc7f9b43122bc3deef5 (patch)
tree80526481ea15267f3c3516c4468c4b7b7472fc7d /src/bdrem/Config.php
parent83afda94b7d5fc2be341712e2661f6095f608e0d (diff)
downloadbdrem-5f35a084b38723da7b505bc7f9b43122bc3deef5.tar.gz
bdrem-5f35a084b38723da7b505bc7f9b43122bc3deef5.zip
load config file from different locations, including phar
Diffstat (limited to 'src/bdrem/Config.php')
-rw-r--r--src/bdrem/Config.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/bdrem/Config.php b/src/bdrem/Config.php
index 65e353d..a79b1b3 100644
--- a/src/bdrem/Config.php
+++ b/src/bdrem/Config.php
@@ -9,19 +9,37 @@ class Config
public $daysNext = 7;
public $locale;
public $stopOnEmpty = false;
+
+ public $cfgFiles = array();
public $cfgFileExists;
public function load()
{
- $f = __DIR__ . '/../../data/bdrem.config.php';
- if (file_exists($f)) {
- $this->cfgFileExists = true;
- return $this->loadFile($f);
+ $this->loadConfigFilePaths();
+ foreach ($this->cfgFiles as $file) {
+ if (file_exists($file)) {
+ $this->cfgFileExists = true;
+ return $this->loadFile($file);
+ }
}
-
$this->cfgFileExists = false;
}
+ protected function loadConfigFilePaths()
+ {
+ $pharFile = \Phar::running();
+ if ($pharFile == '') {
+ $this->cfgFiles[] = __DIR__ . '/../../data/bdrem.config.php';
+ } else {
+ //remove phar:// from the path
+ $this->cfgFiles[] = substr($pharFile, 7) . '.config.php';
+ }
+
+ //TODO: add ~/.config/bdrem.php
+
+ $this->cfgFiles[] = '/etc/bdrem.php';
+ }
+
protected function loadFile($filename)
{
include $filename;