]> git.mxchange.org Git - core.git/blobdiff - framework/bootstrap/class_FrameworkBootstrap.php
Continued:
[core.git] / framework / bootstrap / class_FrameworkBootstrap.php
index ce3da75f5beba34ec3c6b20ab881c7ef2183e2ad..a0ab9ba648e7a5ea8b147dfe23d4529ef08407d6 100644 (file)
@@ -68,6 +68,11 @@ final class FrameworkBootstrap {
         */
        private static $configurationInstance = NULL;
 
+       /**
+        * Database instance
+        */
+       private static $databaseInstance = NULL;
+
        /*
         * Includes applications may have. They will be tried in the given order,
         * some will become soon deprecated.
@@ -117,24 +122,6 @@ final class FrameworkBootstrap {
                return self::$configurationInstance;
        }
 
-       /**
-        * Getter for request instance
-        *
-        * @return      $requestInstance        An instance of a Requestable class
-        */
-       public static function getRequestInstance () {
-               return self::$requestInstance;
-       }
-
-       /**
-        * Getter for response instance
-        *
-        * @return      $responseInstance       An instance of a Responseable class
-        */
-       public static function getResponseInstance () {
-               return self::$responseInstance;
-       }
-
        /**
         * "Getter" to get response/request type from analysis of the system.
         *
@@ -235,7 +222,7 @@ final class FrameworkBootstrap {
                } // END - if
 
                // Load it
-               require $fileInstance->getPathname();
+               require_once $fileInstance->getPathname();
 
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
@@ -283,7 +270,7 @@ final class FrameworkBootstrap {
 
                /*
                 * 3) Now, that there are all request parameters being available, check
-                *    if 'app' is supplied. If it is not found, abort execution, if
+                *    if 'application' is supplied. If it is not found, abort execution, if
                 *    found, continue below with next step.
                 */
                self::validateApplicationParameter();
@@ -375,13 +362,10 @@ final class FrameworkBootstrap {
                        ));
                }
 
-               // Set it in registry
-               GenericRegistry::getRegistry()->addInstance('application', $applicationInstance);
-
                // Now call all methods in one go
                foreach (array('setupApplicationData', 'initApplication', 'launchApplication') as $methodName) {
                        // Debug message
-                       //* NOISY-DEBUG: */ printf('[%s:%d]: Calling methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
+                       //*NOISY-DEBUG: */ printf('[%s:%d]: Calling methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
 
                        // Call method
                        call_user_func(array($applicationInstance, $methodName));
@@ -398,7 +382,7 @@ final class FrameworkBootstrap {
                $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Is the database instance already set?
-               if ($applicationInstance instanceof DatabaseConnector) {
+               if (self::getDatabaseInstance() instanceof DatabaseConnector) {
                        // Yes, then abort here
                        throw new BadMethodCallException('Method called twice.');
                } // END - if
@@ -410,7 +394,7 @@ final class FrameworkBootstrap {
                $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
 
                // Set it in application helper
-               $applicationInstance->setDatabaseInstance($connectionInstance);
+               self::setDatabaseInstance($connectionInstance);
        }
 
        /**
@@ -493,7 +477,21 @@ final class FrameworkBootstrap {
         * @todo        Test more fields
         */
        public static function isHttpSecured () {
-               return (isset($_SERVER['HTTPS']));
+               return (
+                       (
+                               (
+                                       isset($_SERVER['HTTPS'])
+                               ) && (
+                                       strtolower($_SERVER['HTTPS']) == 'on'
+                               )
+                       ) || (
+                               (
+                                       isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
+                               ) && (
+                                       strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'
+                               )
+                       )
+               );
        }
 
        /**
@@ -508,7 +506,7 @@ final class FrameworkBootstrap {
                // Do we have HTTPS?
                if (self::isHttpSecured()) {
                        // Add the >s< for HTTPS
-                       $protocol = 's';
+                       $protocol = 'https';
                } // END - if
 
                // Construct the full URL and secure it against CSRF attacks
@@ -613,7 +611,7 @@ final class FrameworkBootstrap {
        }
 
        /**
-        * 3) Validate parameter 'app' if it is set and the application is there.
+        * 3) Validate parameter 'application' if it is set and the application is there.
         *
         * @return      void
         */
@@ -656,6 +654,25 @@ final class FrameworkBootstrap {
                self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
                self::getConfigurationInstance()->setConfigEntry('detected_app_name'     , $application);
        }
+
+       /**
+        * Getter for request instance
+        *
+        * @return      $requestInstance        An instance of a Requestable class
+        */
+       public static function getRequestInstance () {
+               return self::$requestInstance;
+       }
+
+       /**
+        * Getter for response instance
+        *
+        * @return      $responseInstance       An instance of a Responseable class
+        */
+       public static function getResponseInstance () {
+               return self::$responseInstance;
+       }
+
        /**
         * Setter for request instance
         *
@@ -676,4 +693,24 @@ final class FrameworkBootstrap {
                self::$responseInstance = $responseInstance;
        }
 
+       /**
+        * Setter for database instance
+        *
+        * @param       $databaseInstance       An instance of a DatabaseConnection class
+        * @return      void
+        */
+       public static function setDatabaseInstance (DatabaseConnection $databaseInstance) {
+               self::$databaseInstance = $databaseInstance;
+       }
+
+       /**
+        * Getter for database instance
+        *
+        * @return      $databaseInstance       An instance of a DatabaseConnection class
+        */
+       public static function getDatabaseInstance () {
+               // Return instance
+               return self::$databaseInstance;
+       }
+
 }