+
+ /**
+ * Finds the path to the configuration file.
+ *
+ * The following locations are tried:
+ * - Git checkout: data/callnotifier.config.php
+ * - ~/.config/callnotifier.config.php
+ * - /etc/callnotifier.config.php
+ *
+ * @return string Full path of config file or NULL if no file found
+ */
+ protected function getConfigFile()
+ {
+ if (basename(dirname(__DIR__)) == 'src'
+ && file_exists(__DIR__ . '/../../data/callnotifier.config.php')
+ ) {
+ return __DIR__ . '/../../data/callnotifier.config.php';
+ }
+
+ if (isset($_ENV['HOME'])) {
+ $file = $_ENV['HOME'] . '/.config/callnotifier.config.php';
+ if (file_exists($file)) {
+ return $file;
+ }
+ }
+
+ $file = '/etc/callnotifier.config.php';
+ if (file_exists($file)) {
+ return $file;
+ }
+
+ return null;
+ }