]> git.mxchange.org Git - city.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 15:00:05 +0000 (16:00 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 15:00:05 +0000 (16:00 +0100)
- ApplicationHelper no longer should hold application's data and a
  "self instance" as this is now all done in BaseApplication class
- BaseFrameworkSystem->getConfigInstance() is now removed, always use
  non-monolithic FrameworkBootstrap::getConfigurationInstance() instead
- convertToClassName() is now in StringUtils
- updated core framework

Signed-off-by: Roland Häder <roland@mxchange.org>
application/city/class_ApplicationHelper.php
application/city/classes/city_daemon/class_BaseCityDaemon.php
application/city/classes/commands/html/class_CityHtmlCityUserLoginCommand.php
application/city/classes/commands/html/class_CityHtmlLoginAreaCommand.php
application/city/classes/commands/html/class_CityHtmlResendLinkCommand.php
application/city/classes/database/frontend/city_entities/sections/class_CitySectionsDatabaseWrapper.php
application/city/classes/factories/city_daemon/class_CityDaemonFactory.php
application/city/classes/login/helper/class_CityLoginHelper.php
application/city/classes/registration/class_CityRegistration.php
application/city/config.php
core

index 17bf18b79def945d127a7ccfdb9b44f445254ea0..9156d8900f015f01499ff57db0e8cabbc504fa21 100644 (file)
@@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Loader\ClassLoader;
 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 /**
  * A class holding general data about the application and some methods for
@@ -51,26 +52,6 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class ApplicationHelper extends BaseApplication implements ManageableApplication, Registerable {
-       /**
-        * The version number of this application
-        */
-       private $appVersion = '';
-
-       /**
-        * The human-readable name for this application
-        */
-       private $appName = '';
-
-       /**
-        * The short uni*-like name for this application
-        */
-       private $shortName = '';
-
-       /**
-        * An instance of this class
-        */
-       private static $selfInstance = NULL;
-
        /**
         * Private constructor
         *
@@ -88,71 +69,13 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
         */
        public static final function getSelfInstance () {
                // Is the instance there?
-               if (is_null(self::$selfInstance)) {
-                       self::$selfInstance = new ApplicationHelper();
-               } // END - if
+               if (is_null(self::getApplicationInstance())) {
+                       // Set it
+                       self::setApplicationInstance(new ApplicationHelper());
+               }
 
                // Return the instance
-               return self::$selfInstance;
-       }
-
-       /**
-        * Getter for the version number
-        *
-        * @return      $appVersion     The application's version number
-        */
-       public final function getAppVersion () {
-               return $this->appVersion;
-       }
-       /**
-        * Setter for the version number
-        *
-        * @param       $appVersion     The application's version number
-        * @return      void
-        */
-       public final function setAppVersion ($appVersion) {
-               // Cast and set it
-               $this->appVersion = (string) $appVersion;
-       }
-
-       /**
-        * Getter for human-readable name
-        *
-        * @return      $appName        The application's human-readable name
-        */
-       public final function getAppName () {
-               return $this->appName;
-       }
-
-       /**
-        * Setter for human-readable name
-        *
-        * @param       $appName        The application's human-readable name
-        * @return      void
-        */
-       public final function setAppName ($appName) {
-               // Cast and set it
-               $this->appName = (string) $appName;;
-       }
-
-       /**
-        * Getter for short uni*-like name
-        *
-        * @return      $shortName      The application's short uni*-like name
-        */
-       public final function getAppShortName () {
-               return $this->shortName;
-       }
-
-       /**
-        * Setter for short uni*-like name
-        *
-        * @param       $shortName      The application's short uni*-like name
-        * @return      void
-        */
-       public final function setAppShortName ($shortName) {
-               // Cast and set it
-               $this->shortName = (string) $shortName;
+               return self::getApplicationInstance();
        }
 
        /**
@@ -208,7 +131,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
                // Get a controller resolver
                $resolverClass = sprintf(
                        'Org\Mxchange\City\Resolver\Controller\%s',
-                       self::convertToClassName(sprintf(
+                       StringUtils::convertToClassName(sprintf(
                                '%s_%s_controller_resolver',
                                $this->getAppShortName(),
                                FrameworkBootstrap::getRequestTypeFromSystem()
index d4c5382b093cbc1c66b3b12938945057f6bb2449..5e743d1908d1e8ab133d593d9f2fe905b5c3f370 100644 (file)
@@ -222,7 +222,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda
         */
        public function updateCityData () {
                // Set some dummy configuration entries, e.g. city_status
-               $this->getConfigInstance()->setConfigEntry('city_status', $this->getStateInstance()->getStateName());
+               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('city_status', $this->getStateInstance()->getStateName());
        }
 
        /**
index c0949a666d0d95260759083e776ca2d7cf8a93a2..edb4c67bd285aa273beab567f1c6e21a9242ee3d 100644 (file)
@@ -107,7 +107,7 @@ class CityHtmlCityUserLoginCommand extends BaseCommand implements Commandable {
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Which login type do we have?
-               switch ($this->getConfigInstance()->getConfigEntry('login_type')) {
+               switch (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type')) {
                        case 'username': // Login via username
                                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter_class'));
                                break;
index a3fb66938270996b17cc80c738d704551edc29fa..bfa8ca1d42a541675f61b665c90c2812840617fa 100644 (file)
@@ -182,7 +182,7 @@ class CityHtmlLoginAreaCommand extends BaseCommand implements Commandable {
                $applicationInstance = $registryInstance->getInstance('application');
 
                // Default action is the one from configuration
-               $this->actionName = $this->convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $this->getConfigInstance()->getConfigEntry('login_default_action');
+               $this->actionName = $this->convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_default_action');
 
                // Get "action" from request
                $actReq = $requestInstance->getRequestElement('action');
index 172ecc6d6ec31fe2d0e8fd59a713b1caef0dc425..55f82f027c22a3731e3960e6c8225f5597bd73f6 100644 (file)
@@ -3,6 +3,7 @@
 namespace Org\Mxchange\City\Command;
 
 // Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Command\BaseCommand;
 use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Controller\Controller;
@@ -93,7 +94,7 @@ class CityHtmlResendLinkCommand extends BaseCommand implements Commandable {
                $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString);
 
                // Re-set config entry to mailer engine
-               $this->getConfigInstance()->setConfigEntry('html_template_class', $this->getConfigInstance()->getConfigEntry('mail_template_class'));
+               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('html_template_class', FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('mail_template_class'));
 
                // Prepare the template engine
                $templateInstance = $this->prepareTemplateInstance($applicationInstance);
index 6f29ee848dbc310dfe588f3560d320802571f96c..2b4d671c9c681bbee93fdd8943fa6c80b5dba091 100644 (file)
@@ -3,6 +3,7 @@
 namespace Org\Mxchange\City\Database\Frontend\Sections;
 
 // Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseWrapper;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
@@ -165,11 +166,11 @@ class CitySectionsDatabaseWrapper extends BaseDatabaseWrapper implements CitySec
                 *
                 * totalInitialSections = (radius + 1) * (radius + 1)
                 */
-               $radius = $this->getConfigInstance()->getConfigEntry('city_max_initial_xy_expansion_radius');
+               $radius = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('city_max_initial_xy_expansion_radius');
 
                // Max up and down ...
-               $maxUp   = $this->getConfigInstance()->getConfigEntry('city_max_initial_up_expansion');
-               $maxDown = $this->getConfigInstance()->getConfigEntry('city_max_initial_down_expansion');
+               $maxUp   = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('city_max_initial_up_expansion');
+               $maxDown = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('city_max_initial_down_expansion');
 
                // Calculate total sections
                $totalSections = (($radius + 1) * ($radius + 1) * $maxUp * ($maxDown + 1));
index bd84eace122816b47efe4f4c0f665ca5d3ff3d91..a44ae87954090b4f5ac177b0de6c4acae084be77 100644 (file)
@@ -3,6 +3,7 @@
 namespace Org\Mxchange\City\Daemon\Factory;
 
 // Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
@@ -59,7 +60,7 @@ class CityDaemonFactory extends ObjectFactory {
                        $cityInstance = GenericRegistry::getRegistry()->getInstance('city');
                } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) {
                        // The default city-mode is from our configuration
-                       $cityMode = $factoryInstance->getConfigInstance()->getConfigEntry('city_default_mode');
+                       $cityMode = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('city_default_mode');
 
                        // Is the city 'mode' parameter set?
                        if ($requestInstance->isRequestElementSet('mode')) {
@@ -70,11 +71,11 @@ class CityDaemonFactory extends ObjectFactory {
                                $requestInstance->setRequestElement('mode', $cityMode);
                        }
 
-                       // Now convert the city-mode in a class name
-                       $className = 'Org\Mxchange\City\Daemon\Simulation\Simulation' . $factoryInstance->convertToClassName($cityMode) . 'CityDaemon';
+                       // Now convert the city-mode in a configuration entry
+                       $configEntry = sprintf('city_%s_daemon_mode_class', $cityMode);
 
                        // Get the city instance
-                       $cityInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
+                       $cityInstance = ObjectFactory::createObjectByConfiguredName($configEntry, array($requestInstance));
 
                        // Get a registry
                        $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
index 1a2db89322d3f3992ad686e11e8a2c6cf4321664..49876c1d86d269ee8025b38db5e07f70d8cd4cef 100644 (file)
@@ -95,7 +95,7 @@ class CityLoginHelper extends BaseLoginHelper implements HelpableLogin {
         * @return      void
         */
        protected function setDefaultAuthMethod () {
-               $this->authMethod = $this->getConfigInstance()->getConfigEntry('auth_method_class');
+               $this->authMethod = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('auth_method_class');
        }
 
        /**
index 3b4ca6d788faa84d5058f99bc2719548e6d55233..5c1e74ba417bc3b2ff737d28166393a1dcd2f062 100644 (file)
@@ -177,7 +177,7 @@ class CityRegistration extends BaseRegistration implements UserRegister {
                $configEntry = 'user_status_unconfirmed';
 
                // Is the confirmation process entirely disabled?
-               if ($this->getConfigInstance()->getConfigEntry('confirm_email_enabled') === 'N') {
+               if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('confirm_email_enabled') === 'N') {
                        // No confirmation of email needed
                        $configEntry = 'user_status_confirmed';
                } // END - if
@@ -200,7 +200,7 @@ class CityRegistration extends BaseRegistration implements UserRegister {
                        }
 
                        // Is this a guest account?
-                       if ((($element == 'username') || ($alias == 'username')) && (FrameworkBootstrap::getRequestInstance()->getRequestElement($element) == $this->getConfigInstance()->getConfigEntry('guest_login_user'))) {
+                       if ((($element == 'username') || ($alias == 'username')) && (FrameworkBootstrap::getRequestInstance()->getRequestElement($element) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('guest_login_user'))) {
                                // Yes, then set the config entry to guest status
                                $configEntry = 'user_status_guest';
                        } // END - if
index bbadaf1707b5dc4a64ebaa8d044095b184d40899..6a602fd6fb708fcc5875bde8f3d2dadc36efa9ce 100644 (file)
@@ -513,6 +513,9 @@ $cfg->setConfigEntry('default_city_console_command', 'daemon');
 // CFG: DEFAULT-CITY-CONSOLE-CONTROLLER
 $cfg->setConfigEntry('default_city_console_controller', 'daemon');
 
+// CFG: CITY-DEFAULT-DAEMON-MODE-CLASS
+$cfg->setConfigEntry('city_default_daemon_mode_class', 'Org\Mxchange\City\Daemon\Simulation\SimulationDefaultCityDaemon');
+
 // CFG: CITY-CONSOLE-CMD-DAEMON-RESOLVER-CLASS
 $cfg->setConfigEntry('city_console_cmd_daemon_resolver_class', 'Org\Mxchange\City\Resolver\Command\CityConsoleCommandResolver');
 
diff --git a/core b/core
index c15d02389e67a880e7b4c6b19f2b06722efa4e6f..513812814a5a17022d414727e5a4c6d0823fe5f6 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit c15d02389e67a880e7b4c6b19f2b06722efa4e6f
+Subproject commit 513812814a5a17022d414727e5a4c6d0823fe5f6