From d0f50af0ebbdbb3971fb854b5e2509b02b1496ee Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Thu, 21 Dec 2017 22:42:34 +0100 Subject: [PATCH] Resolved #107. Fallback configuration has been implemented/ --- src/Config/config.cache.php | 45 +++++++++++++ src/Config/config.contact.php | 42 +++++++++++++ src/Config/config.core.php | 35 +++++++++++ src/Config/config.database.php | 63 +++++++++++++++++++ src/Config/config.encryption.php | 35 +++++++++++ src/Config/config.error.php | 37 +++++++++++ .../Config/config.main.php | 30 +++++++++ .../Config/config.mimes.php | 30 +++++++++ src/Config/config.routes.php | 34 ++++++++++ .../Config/config.routing.php | 30 +++++++++ .../Config/config.security.php | 30 +++++++++ src/FuzeWorks/Config.php | 8 +++ tests/application/Config/config.cache.php | 16 ----- tests/application/Config/config.contact.php | 12 ---- tests/application/Config/config.core.php | 10 --- tests/application/Config/config.database.php | 33 ---------- .../application/Config/config.encryption.php | 5 -- tests/application/Config/config.error.php | 5 -- tests/application/Config/config.routes.php | 4 -- 19 files changed, 419 insertions(+), 85 deletions(-) create mode 100644 src/Config/config.cache.php create mode 100644 src/Config/config.contact.php create mode 100644 src/Config/config.core.php create mode 100644 src/Config/config.database.php create mode 100644 src/Config/config.encryption.php create mode 100644 src/Config/config.error.php rename {tests/application => src}/Config/config.main.php (66%) rename {tests/application => src}/Config/config.mimes.php (88%) create mode 100644 src/Config/config.routes.php rename {tests/application => src}/Config/config.routing.php (73%) rename {tests/application => src}/Config/config.security.php (69%) delete mode 100644 tests/application/Config/config.cache.php delete mode 100644 tests/application/Config/config.contact.php delete mode 100644 tests/application/Config/config.core.php delete mode 100644 tests/application/Config/config.database.php delete mode 100644 tests/application/Config/config.encryption.php delete mode 100644 tests/application/Config/config.error.php delete mode 100644 tests/application/Config/config.routes.php diff --git a/src/Config/config.cache.php b/src/Config/config.cache.php new file mode 100644 index 0000000..352820f --- /dev/null +++ b/src/Config/config.cache.php @@ -0,0 +1,45 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ + +return array( + 'cache_query_string' => false, + 'memcached' => array( + 'default' => array( + 'hostname' => '127.0.0.1', + 'port' => '11211', + 'weight' => '1', + ) + ), + 'redis' => array( + '' => '' + ) +); \ No newline at end of file diff --git a/src/Config/config.contact.php b/src/Config/config.contact.php new file mode 100644 index 0000000..39549c6 --- /dev/null +++ b/src/Config/config.contact.php @@ -0,0 +1,42 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ + +return array( + 'contact_email' => '', + 'contact_name' => '', + 'contact_adress' => '', + 'contact_phone' => '', + 'contact_postal_code' => '', + 'contact_region' => '', + 'contact_country' => '', + 'contact_city' => '', +); diff --git a/src/Config/config.core.php b/src/Config/config.core.php new file mode 100644 index 0000000..06070d0 --- /dev/null +++ b/src/Config/config.core.php @@ -0,0 +1,35 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ + +return array( + 'enable_events' => true +); diff --git a/src/Config/config.database.php b/src/Config/config.database.php new file mode 100644 index 0000000..eaf3da7 --- /dev/null +++ b/src/Config/config.database.php @@ -0,0 +1,63 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ + +return array( + 'active_group' => 'default', + 'query_builder' => true, + 'databases' => array( + + 'default' => array( + 'dsn' => '', + 'hostname' => '', + 'username' => '', + 'password' => '', + 'database' => '', + 'dbdriver' => '', + 'subdriver'=> '', + 'dbprefix' => '', + 'pconnect' => FALSE, + 'db_debug' => FALSE, + 'cache_on' => FALSE, + 'char_set' => 'utf8', + 'dbcollat' => 'utf8_general_ci', + 'swap_pre' => '', + 'encrypt' => FALSE, + 'compress' => FALSE, + 'stricton' => FALSE, + 'failover' => array(), + ), + + + ), +); + + diff --git a/src/Config/config.encryption.php b/src/Config/config.encryption.php new file mode 100644 index 0000000..56e72ef --- /dev/null +++ b/src/Config/config.encryption.php @@ -0,0 +1,35 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ + +return array( + 'encryption_key' => '', +); diff --git a/src/Config/config.error.php b/src/Config/config.error.php new file mode 100644 index 0000000..3b0bd5f --- /dev/null +++ b/src/Config/config.error.php @@ -0,0 +1,37 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ + +return array( + 'error_reporting' => true, + 'log_to_file' => false, + 'logger_template' => 'logger_default', +); \ No newline at end of file diff --git a/tests/application/Config/config.main.php b/src/Config/config.main.php similarity index 66% rename from tests/application/Config/config.main.php rename to src/Config/config.main.php index 1a2872a..6799127 100644 --- a/tests/application/Config/config.main.php +++ b/src/Config/config.main.php @@ -1,4 +1,34 @@ . + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ return array( 'base_url' => '', diff --git a/tests/application/Config/config.mimes.php b/src/Config/config.mimes.php similarity index 88% rename from tests/application/Config/config.mimes.php rename to src/Config/config.mimes.php index b03d134..f83d854 100644 --- a/tests/application/Config/config.mimes.php +++ b/src/Config/config.mimes.php @@ -1,4 +1,34 @@ . + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ /* | ------------------------------------------------------------------- diff --git a/src/Config/config.routes.php b/src/Config/config.routes.php new file mode 100644 index 0000000..bfb3b5f --- /dev/null +++ b/src/Config/config.routes.php @@ -0,0 +1,34 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ + +return array( +); diff --git a/tests/application/Config/config.routing.php b/src/Config/config.routing.php similarity index 73% rename from tests/application/Config/config.routing.php rename to src/Config/config.routing.php index 3b01357..15c3a62 100644 --- a/tests/application/Config/config.routing.php +++ b/src/Config/config.routing.php @@ -1,4 +1,34 @@ . + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ return array( diff --git a/tests/application/Config/config.security.php b/src/Config/config.security.php similarity index 69% rename from tests/application/Config/config.security.php rename to src/Config/config.security.php index 5254097..45f0d88 100644 --- a/tests/application/Config/config.security.php +++ b/src/Config/config.security.php @@ -1,4 +1,34 @@ . + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://techfuze.net/fuzeworks + * @since Version 1.1.1 + * + * @version Version 1.1.1 + */ return array( diff --git a/src/FuzeWorks/Config.php b/src/FuzeWorks/Config.php index 100fb53..c7bccb9 100644 --- a/src/FuzeWorks/Config.php +++ b/src/FuzeWorks/Config.php @@ -127,6 +127,14 @@ class Config } } + // Try fallback + $file = Core::$coreDir . DS . 'Config' . DS . 'config.' . $configName . '.php'; + if (file_exists($file)) + { + // Load object + return new ConfigORM($file); + } + throw new ConfigException("Could not load config. File $configName not found", 1); } diff --git a/tests/application/Config/config.cache.php b/tests/application/Config/config.cache.php deleted file mode 100644 index a0a933e..0000000 --- a/tests/application/Config/config.cache.php +++ /dev/null @@ -1,16 +0,0 @@ - '', - 'cache_query_string' => false, - 'memcached' => array( - 'default' => array( - 'hostname' => '127.0.0.1', - 'port' => '11211', - 'weight' => '1', - ) - ), - 'redis' => array( - '' => '' - ) -); \ No newline at end of file diff --git a/tests/application/Config/config.contact.php b/tests/application/Config/config.contact.php deleted file mode 100644 index d8d8382..0000000 --- a/tests/application/Config/config.contact.php +++ /dev/null @@ -1,12 +0,0 @@ - '', - 'contact_name' => '', - 'contact_adress' => '', - 'contact_phone' => '', - 'contact_postal_code' => '', - 'contact_region' => '', - 'contact_country' => '', - 'contact_city' => '', -); diff --git a/tests/application/Config/config.core.php b/tests/application/Config/config.core.php deleted file mode 100644 index 1ef8b02..0000000 --- a/tests/application/Config/config.core.php +++ /dev/null @@ -1,10 +0,0 @@ - false, - 'enable_events' => true, - 'composer_autoloader' => '', - 'registry_caching' => false, - 'registry_caching_method' => 'file', - 'registry_caching_time' => 300, -); diff --git a/tests/application/Config/config.database.php b/tests/application/Config/config.database.php deleted file mode 100644 index 277bad0..0000000 --- a/tests/application/Config/config.database.php +++ /dev/null @@ -1,33 +0,0 @@ - 'default', - 'query_builder' => true, - 'databases' => array( - - 'default' => array( - 'dsn' => '', - 'hostname' => '', - 'username' => '', - 'password' => '', - 'database' => '', - 'dbdriver' => '', - 'subdriver'=> '', - 'dbprefix' => '', - 'pconnect' => FALSE, - 'cache_on' => FALSE, - 'cachedir' => 'Application/Cache', - 'char_set' => 'utf8', - 'dbcollat' => 'utf8_general_ci', - 'swap_pre' => '', - 'encrypt' => FALSE, - 'compress' => FALSE, - 'stricton' => FALSE, - 'failover' => array(), - ), - - - ), -); - - diff --git a/tests/application/Config/config.encryption.php b/tests/application/Config/config.encryption.php deleted file mode 100644 index 4e70c30..0000000 --- a/tests/application/Config/config.encryption.php +++ /dev/null @@ -1,5 +0,0 @@ - '', -); diff --git a/tests/application/Config/config.error.php b/tests/application/Config/config.error.php deleted file mode 100644 index dc5844b..0000000 --- a/tests/application/Config/config.error.php +++ /dev/null @@ -1,5 +0,0 @@ - true, - 'log_to_file' => false, - 'logger_template' => 'logger_default', -) ; \ No newline at end of file diff --git a/tests/application/Config/config.routes.php b/tests/application/Config/config.routes.php deleted file mode 100644 index 9a25907..0000000 --- a/tests/application/Config/config.routes.php +++ /dev/null @@ -1,4 +0,0 @@ -