]> git.mxchange.org Git - core.git/blobdiff - framework/bootstrap/class_FrameworkBootstrap.php
Continued:
[core.git] / framework / bootstrap / class_FrameworkBootstrap.php
index a37c6bf95a8200fa770050389d007f1e52331033..ce3da75f5beba34ec3c6b20ab881c7ef2183e2ad 100644 (file)
@@ -1,23 +1,23 @@
 <?php
 // Own namespace
-namespace CoreFramework\Bootstrap;
+namespace Org\Mxchange\CoreFramework\Bootstrap;
 
 // Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
-use CoreFramework\Connection\Database\DatabaseConnection;
-use CoreFramework\Connector\Database\DatabaseConnector;
-use CoreFramework\Console\Tools\ConsoleTools;
-use CoreFramework\EntryPoint\ApplicationEntryPoint;
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Generic\NullPointerException;
-use CoreFramework\Helper\Application\ApplicationHelper;
-use CoreFramework\Loader\ClassLoader;
-use CoreFramework\Manager\ManageableApplication;
-use CoreFramework\Middleware\Debug\DebugMiddleware;
-use CoreFramework\Object\BaseFrameworkSystem;
-use CoreFramework\Registry\Registry;
-use CoreFramework\Request\Requestable;
-use CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration;
+use Org\Mxchange\CoreFramework\Connection\Database\DatabaseConnection;
+use Org\Mxchange\CoreFramework\Connector\Database\DatabaseConnector;
+use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools;
+use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
+use Org\Mxchange\CoreFramework\Loader\ClassLoader;
+use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
 
 // Import SPL stuff
 use \BadMethodCallException;
@@ -63,6 +63,11 @@ final class FrameworkBootstrap {
         */
        private static $responseInstance = NULL;
 
+       /**
+        * Instance of a FrameworkConfiguration class
+        */
+       private static $configurationInstance = NULL;
+
        /*
         * Includes applications may have. They will be tried in the given order,
         * some will become soon deprecated.
@@ -96,6 +101,22 @@ final class FrameworkBootstrap {
                // Prevent making instances from this "utilities" class
        }
 
+       /**
+        * Some "getter" for a configuration instance, making sure, it is unique
+        *
+        * @return      $configurationInstance  An instance of a FrameworkConfiguration class
+        */
+       public static function getConfigurationInstance () {
+               // Is the instance there?
+               if (is_null(self::$configurationInstance)) {
+                       // Init new instance
+                       self::$configurationInstance = new FrameworkConfiguration();
+               } // END - if
+
+               // Return it
+               return self::$configurationInstance;
+       }
+
        /**
         * Getter for request instance
         *
@@ -277,8 +298,8 @@ final class FrameworkBootstrap {
         */
        public static function prepareApplication () {
                // Configuration entry 'detected_app_name' must be set, get it here, including full path
-               $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_app_name');
-               $fullPath    = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_full_app_path');
+               $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
+               $fullPath    = self::getConfigurationInstance()->getConfigEntry('detected_full_app_path');
 
                /*
                 * Now check and load all files, found deprecated files will throw a
@@ -325,12 +346,12 @@ final class FrameworkBootstrap {
         */
        public static function startApplication () {
                // Configuration entry 'detected_app_name' must be set, get it here
-               $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_app_name');
+               $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
 
                // Is there an application helper instance?
                $applicationInstance = call_user_func_array(
                        array(
-                               'CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
+                               'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
                        ), array()
                );
 
@@ -339,7 +360,7 @@ final class FrameworkBootstrap {
                        // Something went wrong!
                        ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
                                $application,
-                               'CoreFramework\Helper\Application\ApplicationHelper'
+                               'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper'
                        ));
                } elseif (!is_object($applicationInstance)) {
                        // No object!
@@ -355,7 +376,7 @@ final class FrameworkBootstrap {
                }
 
                // Set it in registry
-               Registry::getRegistry()->addInstance('app', $applicationInstance);
+               GenericRegistry::getRegistry()->addInstance('application', $applicationInstance);
 
                // Now call all methods in one go
                foreach (array('setupApplicationData', 'initApplication', 'launchApplication') as $methodName) {
@@ -383,7 +404,7 @@ final class FrameworkBootstrap {
                } // END - if
 
                // Initialize database layer
-               $databaseInstance = ObjectFactory::createObjectByConfiguredName(FrameworkConfiguration::getSelfInstance()->getConfigEntry('database_type') . '_class');
+               $databaseInstance = ObjectFactory::createObjectByConfiguredName(self::getConfigurationInstance()->getConfigEntry('database_type') . '_class');
 
                // Prepare database instance
                $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
@@ -550,10 +571,10 @@ final class FrameworkBootstrap {
         */
        private static function scanFrameworkClasses () {
                // Include the class loader function
-               require FrameworkConfiguration::getSelfInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
+               require self::getConfigurationInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
 
                // Register auto-load function with the SPL
-               spl_autoload_register('CoreFramework\Loader\ClassLoader::autoLoad');
+               spl_autoload_register('Org\Mxchange\CoreFramework\Loader\ClassLoader::autoLoad');
 
                // Scan for all framework classes, exceptions and interfaces
                ClassLoader::scanFrameworkClasses();
@@ -571,7 +592,7 @@ final class FrameworkBootstrap {
                $requestType = self::getRequestTypeFromSystem();
 
                // Create a new request object
-               $requestInstance = ObjectFactory::createObjectByName(sprintf('CoreFramework\Request\%sRequest', BaseFrameworkSystem::convertToClassName($request)));
+               $requestInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Request\%sRequest', BaseFrameworkSystem::convertToClassName($request)));
 
                // Remember request instance here
                self::setRequestInstance($requestInstance);
@@ -584,7 +605,7 @@ final class FrameworkBootstrap {
                } // END - if
 
                // ... and a new response object
-               $responseClass = sprintf('CoreFramework\Response\%sResponse', BaseFrameworkSystem::convertToClassName($request));
+               $responseClass = sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', BaseFrameworkSystem::convertToClassName($request));
                $responseInstance = ObjectFactory::createObjectByName($responseClass);
 
                // Remember response instance here
@@ -619,7 +640,7 @@ final class FrameworkBootstrap {
                // Construct FQPN (Full-Qualified Path Name) for ApplicationHelper class
                $applicationPath = sprintf(
                        '%s%s%s',
-                       FrameworkConfiguration::getSelfInstance()->getConfigEntry('application_base_path'),
+                       self::getConfigurationInstance()->getConfigEntry('application_base_path'),
                        $application,
                        DIRECTORY_SEPARATOR
                );
@@ -632,8 +653,8 @@ final class FrameworkBootstrap {
                } // END - if
 
                // Set the detected application's name and full path for later usage
-               FrameworkConfiguration::getSelfInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
-               FrameworkConfiguration::getSelfInstance()->setConfigEntry('detected_app_name'     , $application);
+               self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
+               self::getConfigurationInstance()->setConfigEntry('detected_app_name'     , $application);
        }
        /**
         * Setter for request instance