]> git.mxchange.org Git - core.git/blobdiff - framework/bootstrap/class_FrameworkBootstrap.php
Continued:
[core.git] / framework / bootstrap / class_FrameworkBootstrap.php
index 08abad5bc42e970ae7afe46733ad735c87f23a15..047bcf894dd20be7d21d0841d90863cab3a19e80 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.
         *
@@ -250,6 +237,7 @@ final class FrameworkBootstrap {
                // Load basic include files to continue bootstrapping
                self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
                self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sclass_BaseFrameworkSystem.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+               self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sutils%sclass_StringUtils.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
                self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
                self::loadInclude(new SplFileInfo(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR)));
 
@@ -283,7 +271,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,9 +363,6 @@ 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
@@ -398,7 +383,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 +395,7 @@ final class FrameworkBootstrap {
                $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
 
                // Set it in application helper
-               $applicationInstance->setDatabaseInstance($connectionInstance);
+               self::setDatabaseInstance($connectionInstance);
        }
 
        /**
@@ -493,7 +478,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 +507,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 +612,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 +655,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 +694,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;
+       }
+
 }