]> git.mxchange.org Git - shipsimu.git/commitdiff
More exceptions added, class loader can now load extra configs
authorRoland Häder <roland@mxchange.org>
Thu, 13 Mar 2008 20:30:59 +0000 (20:30 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 13 Mar 2008 20:30:59 +0000 (20:30 +0000)
application/ship-simu/class_ApplicationHelper.php
inc/config.php
inc/config/class_FrameworkConfiguration.php
inc/includes.php
inc/loader/class_ClassLoader.php

index e141d04f08647918ff953edfd43df1fcf3836d41..ccce7378c793b276335b2a3c2e9b7f136a5860c1 100644 (file)
@@ -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);
index 3a14eaa9c8b7d245437130914495e4792353cdc0..ab944bf11599b7057a678acae0b6e900d0866fb2 100644 (file)
@@ -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]
 ?>
index a1ca42a3aead470ecf98d016c3d3044abc316759..957a3537d86a814ca0fe397a3abfa33971215ca3 100644 (file)
@@ -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
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 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.
         *
index 5cecef88756d542602b14f07b043de476a8fd243..c9158581e7c6ffdce0e64538e0687ef2e1926d15 100644 (file)
@@ -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]
 ?>
index cd065629b3db6e39fb9610b8ded76718d328165b..61e8c216ffe532bb1875c22423acadb39135cb48 100644 (file)
@@ -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