first unit test for configuration sub system added
[mailer.git] / inc / config / class_FrameworkConfiguration.php
index 4a82113f16a3caccd34ff380481a183e02d53498..fc920402b4dc664576b8886f35829cbb9e0c83f8 100644 (file)
@@ -5,13 +5,13 @@
  * NOTE: We cannot put this in inc/classes/ because it would be loaded (again)
  * in the class loader. See inc/loader/class_ClassLoader.php for instance
  *
- * @see        ClassLoader
+ * @see                        ClassLoader
  * @author             Roland Haeder <webmaster@mxchange.org>
  * @version            0.3.0
  * @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
- * 
+ * @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
        }
 
        /**
@@ -128,7 +116,7 @@ class FrameworkConfiguration {
        /**
         * A private include loader
         *
-        * @param               $arrayObject            The array object with all include files
+        * @param       $arrayObject    The array object with all include files
         * @return      void
         */
        private function loadIncludes (ArrayObject $arrayObject) {
@@ -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.
         *
@@ -208,8 +176,11 @@ class FrameworkConfiguration {
                // Cast to string
                $path = (string) $path;
 
+               // Replace backslashes with slashes
+               $path = str_replace("\\", "/", $path);
+
                // Is it defined or not?
-               if (!is_dir($path)) {
+               if ((!is_dir($path)) || (!is_readable($path))) {
                        // Is not a valid path
                        ApplicationEntryPoint::app_die(sprintf("[%s:] Invalid path (not found) specified. Please make sure it is created.",
                                __CLASS__
@@ -241,7 +212,7 @@ class FrameworkConfiguration {
                // Is a valid configuration entry provided?
                if (empty($cfgEntry)) {
                        // Entry is empty
-                       throw new ConfigEntryIsEmptyException(__CLASS__, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY);
+                       throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY);
                } elseif (!isset($this->config[$cfgEntry])) {
                        // Entry was not found!
                        throw new ConfigEntryNotFoundException(array(__CLASS__, $cfgEntry), self::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND);
@@ -272,7 +243,7 @@ class FrameworkConfiguration {
                // Is a valid configuration entry provided?
                if (empty($cfgEntry)) {
                        // Entry is empty
-                       throw new ConfigEntryIsEmptyException(__CLASS__, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY);
+                       throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY);
                }
 
                // Set the configuration value