]> git.mxchange.org Git - core.git/blobdiff - framework/bootstrap/class_FrameworkBootstrap.php
Continued:
[core.git] / framework / bootstrap / class_FrameworkBootstrap.php
index c8141169428e144df086ccd36d49b4a01fcee8e4..9f376df51ba254807866e0160364ccd306620950 100644 (file)
@@ -11,6 +11,7 @@ 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\Localization\ManageableLanguage;
 use Org\Mxchange\CoreFramework\Loader\ClassLoader;
 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
 use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
@@ -18,6 +19,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;
 
 // Import SPL stuff
 use \BadMethodCallException;
@@ -29,7 +31,7 @@ use \SplFileInfo;
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2019 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -73,6 +75,11 @@ final class FrameworkBootstrap {
         */
        private static $databaseInstance = NULL;
 
+       /**
+        * Language system instance
+        */
+       private static $languageInstance = NULL;
+
        /*
         * Includes applications may have. They will be tried in the given order,
         * some will become soon deprecated.
@@ -237,7 +244,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%sclasses%sutils%sstring%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)));
 
@@ -340,7 +347,7 @@ final class FrameworkBootstrap {
                $applicationInstance = call_user_func_array(
                        array(
                                'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
-                       ), array()
+                       ), []
                );
 
                // Some sanity checks
@@ -442,18 +449,11 @@ final class FrameworkBootstrap {
         *
         * @param       $timezone       The timezone string (e.g. Europe/Berlin)
         * @return      $success        If timezone was accepted
-        * @throws      NullPointerException    If $timezone is NULL
         * @throws      InvalidArgumentException        If $timezone is empty
         */
-       public static function setDefaultTimezone ($timezone) {
-               // Is it null?
-               if (is_null($timezone)) {
-                       // Throw NPE
-                       throw new NullPointerException(NULL, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_string($timezone)) {
-                       // Is not a string
-                       throw new InvalidArgumentException(sprintf('timezone[]=%s is not a string', gettype($timezone)));
-               } elseif ((is_string($timezone)) && (empty($timezone))) {
+       public static function setDefaultTimezone (string $timezone) {
+               // Is it set?
+               if (empty($timezone)) {
                        // Entry is empty
                        throw new InvalidArgumentException('timezone is empty');
                }
@@ -591,7 +591,7 @@ final class FrameworkBootstrap {
                $requestType = self::getRequestTypeFromSystem();
 
                // Create a new request object
-               $requestInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Request\%sRequest', BaseFrameworkSystem::convertToClassName($request)));
+               $requestInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Request\%sRequest', StringUtils::convertToClassName($request)));
 
                // Remember request instance here
                self::setRequestInstance($requestInstance);
@@ -604,7 +604,7 @@ final class FrameworkBootstrap {
                } // END - if
 
                // ... and a new response object
-               $responseClass = sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', BaseFrameworkSystem::convertToClassName($request));
+               $responseClass = sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', StringUtils::convertToClassName($request));
                $responseInstance = ObjectFactory::createObjectByName($responseClass);
 
                // Remember response instance here
@@ -714,4 +714,23 @@ final class FrameworkBootstrap {
                return self::$databaseInstance;
        }
 
+       /**
+        * Private getter for language instance
+        *
+        * @return      $languageInstance       An instance of a ManageableLanguage class
+        */
+       public static function getLanguageInstance () {
+               return self::$languageInstance;
+       }
+
+       /**
+        * Setter for language instance
+        *
+        * @param       $languageInstance       An instance of a ManageableLanguage class
+        * @return      void
+        */
+       public static function setLanguageInstance (ManageableLanguage $languageInstance) {
+               self::$languageInstance = $languageInstance;
+       }
+
 }