Renamed Registry -> GenericRegistry to make it clear that this registry does
[core.git] / framework / main / classes / language / class_LanguageSystem.php
index 0c2875ac2c9740666d07ecdb437f151d01be50f0..99df420951bee5bbac8c46b50098256e73c25d25 100644 (file)
@@ -1,12 +1,15 @@
 <?php
 // Own namespace
-namespace CoreFramework\Localization;
+namespace Org\Mxchange\CoreFramework\Localization;
 
 // Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
-use CoreFramework\Object\BaseFrameworkSystem;
-use CoreFramework\Registry\Registerable;
-use CoreFramework\Registry\Registry;
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+
+// Import SPL stuff
+use \InvalidArgumentException;
 
 /**
  * The language sub-system for handling language strings being used in the
@@ -67,7 +70,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage,
         *
         * @param       $languageBasePath       The local base path for all language strings or emty for auto-detection
         * @return      $langInstance   An instance of LanguageSystem
-        * @throws      LanguagePathIsEmptyException    If the provided $languageBasePath is empty
+        * @throws      InvalidArgumentException        If languageBasePath remains empty (@TODO Get rid of that old-lost code)
         * @throws      InvalidLanguagePathStringException      If $languageBasePath is no string
         * @throws      LanguagePathIsNoDirectoryException      If $languageBasePath is no
         *                                                                              directory or not found
@@ -82,20 +85,19 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage,
                if (empty($languageBasePath)) {
                        // No, then attempt "auto-dection":
                        // 1) Get application
-                       $applicationInstance = Registry::getRegistry()->getInstance('app');
+                       $applicationInstance = GenericRegistry::getRegistry()->getInstance('app');
 
                        // 2) Try to build it
-                       $languageBasePath = sprintf('%sapplication/%s/language/',
-                               $langInstance->getConfigInstance()->getConfigEntry('base_path'),
-                               // Don't allow any underscores/dashes in application names
-                               str_replace(array('_', '-'), array('', ''), $applicationInstance->getAppShortName())
+                       $languageBasePath = sprintf('%s%s/language/',
+                               $langInstance->getConfigInstance()->getConfigEntry('application_base_path'),
+                               $applicationInstance->getAppShortName()
                        );
                } // END - if
 
                // Is the base path valid?
                if (empty($languageBasePath)) {
                        // Language path is empty
-                       throw new LanguagePathIsEmptyException($langInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new InvalidArgumentException('languageBasePath is still empty');
                } elseif (!is_string($languageBasePath)) {
                        // Is not a string
                        throw new InvalidLanguagePathStringException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_STRING);
@@ -114,7 +116,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage,
                $langInstance->initLanguageStrings();
 
                // Set language code from default config
-               $langInstance->setLanguageCode(FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_lang'));
+               $langInstance->setLanguageCode(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_lang'));
 
                // Remember this instance
                self::$selfInstance = $langInstance;