diff --git a/.gitignore b/.gitignore index 2f0e4e0..d007109 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .idea logs/ -*configuration.local.php *~ diff --git a/Lib/Configuration.php b/Lib/Configuration.php index bbe6856..34bb61b 100644 --- a/Lib/Configuration.php +++ b/Lib/Configuration.php @@ -60,16 +60,17 @@ class Configuration { // by default, set the session save path to the default value; $this->values['session']['save_path'] = session_save_path(); - if(file_exists($this->custom_config)) { - /** @noinspection PhpIncludeInspection */ - require_once($this->custom_config); - - if(! isset($configuration) || ! is_array($configuration)) { - throw new \RuntimeException("You custom configuration in '{$this->custom_config}' must be in a variable named '\$configuration' and be an array."); - } + if(!file_exists($this->custom_config)) { + throw new \Exception\UsageException('No configuration.local.php file was found. Create it with the proper config.'); + } + + $configuration = include_once $this->custom_config; - $this->values = array_replace_recursive($this->values, $configuration); + if(!is_array($configuration)) { + throw new \RuntimeException("You custom configuration in '{$this->custom_config}' must be in a variable named '\$configuration' and be an array."); } + + $this->values = array_replace_recursive($this->values, $configuration); } private function dotNotationAccess($data, $key, $default=null) diff --git a/configuration.local.php b/configuration.local.php new file mode 100644 index 0000000..3e3be21 --- /dev/null +++ b/configuration.local.php @@ -0,0 +1,44 @@ + array( + 'driver' => 'FreeTDS', + 'server' => '192.168.0.8', + 'port' => '1218', + 'username' => 'alcoda', + 'password' => 'alcodaonly', + 'name' => 'netbiblio', + ), + 'solr' => array( + 'server' => '212.147.56.162', + 'port' => '8983', + 'username' => '', + 'password' => '', + 'path' => 'solr/', + 'result_count' => 10, + ), + 'log' => array( + 'file' => '/var/www/webservice/logs/log.txt', + 'format' => '%ip% - [%date%] - %status% %error% - %time% - %func%', + // The greater the verbosity, the more is displayed + // 0 : no log at all + // 1 : log summary + // 2 : log response + 'verbosity' => 1, + ), + 'session' => array( + 'save_path' => '' + ), + 'checkfile_url' => 'http://medias.bibliothequesonore.ch/checkfile.php?', + 'checkfile_url_old' => 'http://fichiers.bibliothequesonore.ch/checkfile.php?', + 'netbiblio_worker_id' => 45, + 'www_employee_id' => 45, + 'www_library_id' => 2, + );;