]> git.mxchange.org Git - core.git/blobdiff - framework/bootstrap/class_FrameworkBootstrap.php
Continued:
[core.git] / framework / bootstrap / class_FrameworkBootstrap.php
index f9ddae7f573f4b5639b785a29a2c3bbb6c4b6115..de4aac3ddb6fc10d6c560ee84871a8d95c1de497 100644 (file)
@@ -9,6 +9,7 @@ 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\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
@@ -19,7 +20,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
+use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 
 // Import SPL stuff
 use \BadMethodCallException;
@@ -31,7 +32,7 @@ use \SplFileInfo;
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -247,10 +248,8 @@ final class FrameworkBootstrap {
         * @throws      InvalidArgumentException        If file was not found or not readable or deprecated
         */
        public static function loadInclude (SplFileInfo $fileInstance) {
-               // Trace message
-               //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance);
-
                // Should be there ...
+               //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance);
                if (!self::isReadableFile($fileInstance)) {
                        // Abort here
                        throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
@@ -264,20 +263,28 @@ final class FrameworkBootstrap {
        }
 
        /**
-        * Does the actual bootstrap
+        * Does the actual bootstrap. I think the amount of statically loaded
+        * include files cannot be reduced here as those files are need to early
+        * in the bootstrap phase. If you can find an other solution than this, with
+        * lesser "static includes" (means not loaded by the class loader), please
+        * let me know.
         *
         * @return      void
         */
        public static function doBootstrap () {
                // Load basic include files to continue bootstrapping
+               //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
                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%sstring%sclass_StringUtils.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+               self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sutils%sstrings%sclass_StringUtils.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, 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)));
 
                // Load global configuration
                self::loadInclude(new SplFileInfo(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php')));
+
+               // Trace message
+               //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
        }
 
        /**
@@ -353,6 +360,9 @@ final class FrameworkBootstrap {
                        self::loadInclude($fileInstance);
                }
 
+               // After this, sort the configuration array
+               self::getConfigurationInstance()->sortConfigurationArray();
+
                // Scan for application's classes, exceptions and interfaces
                ClassLoader::scanApplicationClasses();
        }
@@ -392,12 +402,10 @@ final class FrameworkBootstrap {
                }
 
                // 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);
-
+               foreach (['setupApplicationData', 'initApplication', 'launchApplication'] as $methodName) {
                        // Call method
-                       call_user_func(array($applicationInstance, $methodName));
+                       //*NOISY-DEBUG: */ printf('[%s:%d]: Calling methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
+                       call_user_func([$applicationInstance, $methodName]);
                }
        }
 
@@ -476,7 +484,7 @@ final class FrameworkBootstrap {
                // Is it set?
                if (empty($timezone)) {
                        // Entry is empty
-                       throw new InvalidArgumentException('timezone is empty');
+                       throw new InvalidArgumentException('Parameter "timezone" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
 
                // Default success
@@ -590,7 +598,7 @@ final class FrameworkBootstrap {
         * @return      void
         */
        private static function scanFrameworkClasses () {
-               // Include the class loader function
+               // Include class loader
                require self::getConfigurationInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
 
                // Register auto-load function with the SPL
@@ -625,8 +633,7 @@ final class FrameworkBootstrap {
                }
 
                // ... and a new response object
-               $responseClass = sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', StringUtils::convertToClassName($request));
-               $responseInstance = ObjectFactory::createObjectByName($responseClass);
+               $responseInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', StringUtils::convertToClassName($request)));
 
                // Remember response instance here
                self::setResponseInstance($responseInstance);