Code merge from latest ship-simu code
[mailer.git] / inc / config / class_FrameworkConfiguration.php
index 510bd0749ef48bfcd673280e4b4658cec8c7fef7..6c81052d52ae1e4b41a268891ae847539d6e377a 100644 (file)
@@ -5,19 +5,27 @@
  * 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.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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
@@ -35,12 +43,10 @@ class FrameworkConfiguration {
        const EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND = 0xc01;
 
        /**
-        * Private constructor
+        * Protected constructor
         */
-       private function __construct () {
-               // Initialize both include lists
-               $this->moreIncPre  = new ArrayObject();
-               $this->moreIncPost = new ArrayObject();
+       protected function __construct () {
+               // Empty for now
        }
 
        /**
@@ -110,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) {
@@ -138,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.
         *
@@ -190,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__
@@ -223,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);
@@ -254,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