From 87db91afa01eda4ca4f3b72a3f795cd2cc28d6f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 13 Mar 2008 20:30:59 +0000 Subject: [PATCH] More exceptions added, class loader can now load extra configs --- .../ship-simu/class_ApplicationHelper.php | 1 + inc/config.php | 12 ------- inc/config/class_FrameworkConfiguration.php | 36 ++----------------- inc/includes.php | 23 ++---------- inc/loader/class_ClassLoader.php | 24 ++++++++++++- 5 files changed, 29 insertions(+), 67 deletions(-) diff --git a/application/ship-simu/class_ApplicationHelper.php b/application/ship-simu/class_ApplicationHelper.php index e141d04..ccce737 100644 --- a/application/ship-simu/class_ApplicationHelper.php +++ b/application/ship-simu/class_ApplicationHelper.php @@ -164,6 +164,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica */ public final function entryPoint () { // Handle the request + $this->handleRequest(); // Prepare the template engine $tplEngine = $this->prepareTemplateEngine($this); diff --git a/inc/config.php b/inc/config.php index 3a14eaa..ab944bf 100644 --- a/inc/config.php +++ b/inc/config.php @@ -141,17 +141,5 @@ $cfg->setConfigEntry("default_application", "selector"); // CFG: VERBOSE-LEVEL $cfg->setConfigEntry("verbose_level", 0); -// Shall we include config-local.php where you can configure some things? Then -// We need to do some things: -// -// First generate FQFN -$localConfig = sprintf("%sinc/config-local%s", PATH, $cfg->readConfig("php_extension")); - -// Second is the file there and readable? -if ((file_exists($localConfig)) && (is_readable($localConfig))) { - // The third step to load it - require_once($localConfig); -} - // [EOF] ?> diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index a1ca42a..957a353 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -11,7 +11,7 @@ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.mxchange.org - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -26,16 +26,6 @@ * along with this program. If not, see . */ class FrameworkConfiguration { - /** - * Include files which shall be included before the main loader. - */ - private $moreIncPre = null; - - /** - * Include files which shall be included after the main loader. - */ - private $moreIncPost = null; - /** * The framework's main configuration array which will be initialized with * hard-coded configuration data and might be overwritten/extended by @@ -56,9 +46,7 @@ class FrameworkConfiguration { * Private constructor */ private function __construct () { - // Initialize both include lists - $this->moreIncPre = new ArrayObject(); - $this->moreIncPost = new ArrayObject(); + // Empty for now } /** @@ -156,26 +144,6 @@ class FrameworkConfiguration { } } - /** - * Load all includes before main loader and clears the array after usage - * - * @return void - */ - public function loadPreIncludes () { - $this->loadIncludes($this->moreIncPre); - unset($this->moreIncPre); - } - - /** - * Load all includes after main loader and clears the array after usage - * - * @return void - */ - public function loadPostIncludes () { - $this->loadIncludes($this->moreIncPost); - unset($this->moreIncPost); - } - /** * Define the database type which must be valid and will not be verified. * diff --git a/inc/includes.php b/inc/includes.php index 5cecef8..c915858 100644 --- a/inc/includes.php +++ b/inc/includes.php @@ -35,26 +35,9 @@ if (is_dir(sprintf("%sdevel", PATH))) { ClassLoader::getInstance()->loadClasses("devel"); } -/** - * Load additional include files before main load - */ -FrameworkConfiguration::getInstance()->loadPreIncludes(); - -/** - * Load all main include files - * - * +++ MAIN LOADER! +++ - * - */ - -/////////////////////////////////////////////////// -// Maybe we need this place for future releases? // -/////////////////////////////////////////////////// - -/** - * Load additional include files after main load - */ -FrameworkConfiguration::getInstance()->loadPostIncludes(); +// Shall we include additional configs where you can configure some things? Then +// Load matching config +ClassLoader::getInstance()->loadExtraConfigs(); // [EOF] ?> diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php index cd06562..61e8c21 100644 --- a/inc/loader/class_ClassLoader.php +++ b/inc/loader/class_ClassLoader.php @@ -212,7 +212,7 @@ class ClassLoader { //* DEBUG: */ print "Suffix=".$this->suffix."(".substr($dirClass2, -$this->sufLen, $this->sufLen).")\n"; //* DEBUG: */ print "ENTRY={$dirClass}\n"; if ( - (is_file($dirClass)) + (is_file($dirClass)) && (is_readable($dirClass)) && (substr($dirClass2, 0 , $this->preLen) == $this->prefix) && (substr($dirClass2, -$this->sufLen, $this->sufLen) == $this->suffix) @@ -262,6 +262,28 @@ class ClassLoader { $this->classes = new ArrayObject(); } } + + /** + * Load extra config files + * + * @return void + */ + public function loadExtraConfigs () { + // Backup old prefix + $oldPrefix = $this->prefix; + + // Set new prefix (temporary!) + $this->prefix = "config-"; + + // Set base directory + $basePath = sprintf("%s/inc/config/", PATH); + + // Load all classes from the config directory + $this->loadClasses($basePath); + + // Set the prefix back + $this->prefix = $oldPrefix; + } } // Initial load of core classes and the FrameworkDirectoryPointer class -- 2.30.2