From 725356dda0e7e6f00dbeaecca7086d22b228365b Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 30 Jul 2014 11:28:56 +0000 Subject: [PATCH] Allow the configuration file to be defined by a PHP constant for phpunit git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1599 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- config.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/config.php b/config.php index f15ae00..08befd5 100644 --- a/config.php +++ b/config.php @@ -20,6 +20,14 @@ class config /** Use the .php to protect the informations */ public $confFile = "./datas/configuration.php"; + /** The constructor can update the confFile variable if it is defined in a + constant */ + public function __construct () + { + if (defined("CONFIGFILE")) + $this->confFile = CONFIGFILE; + } + /** List all the parameters configurable in the software */ public function params () { @@ -40,9 +48,13 @@ class config "confFile)); + _("No configuration file '%s' available and it can't be created"), + $this->confFile)); } + elseif (! is_readable ($this->confFile)) + throw new Exception (sprintf ( + _("The configuration file '%s' is not readable"), + $this->confFile)); $conf = array (); $rc = include ($this->confFile); if ($rc !== 1) @@ -69,6 +81,10 @@ class config "No configuration file '%s' available and it can't be created", $this->confFile)); } + elseif (! is_readable ($this->confFile)) + throw new Exception (sprintf ( + _("The configuration file '%s' is not readable"), + $this->confFile)); if (!is_writeable ($this->confFile)) throw new Exception (sprintf ( "Configuration file '%s' is write protected",