]> git.mxchange.org Git - city.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 07:52:03 +0000 (08:52 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 20:31:47 +0000 (21:31 +0100)
- Application instance in generic registry was a little of an overdoze when
  there is ApplicationHelper::getSelfInstance() around, this means lesser
  method invocations and a bit smaller footprint (one registry entry lesser)
- updated core framework

Signed-off-by: Roland Häder <roland@mxchange.org>
12 files changed:
application/city/classes/city_daemon/class_BaseCityDaemon.php
application/city/classes/city_daemon/default/class_SimulationDefaultCityDaemon.php
application/city/classes/commands/console/class_CityConsoleDaemonCommand.php
application/city/classes/commands/html/class_CityHtmlConfirmCommand.php
application/city/classes/commands/html/class_CityHtmlLoginAreaCommand.php
application/city/classes/commands/html/class_CityHtmlLoginCommand.php
application/city/classes/commands/html/class_CityHtmlLoginFailedCommand.php
application/city/classes/commands/html/class_CityHtmlLogoutDoneCommand.php
application/city/classes/commands/html/class_CityHtmlResendLinkCommand.php
application/city/classes/factories/city_daemon/class_CityDaemonFactory.php
core
index.php

index 11c6b3335526c0eaf5fd8e9844a7efe3b0f35aff..e45a0f7522e3956a40804d2c3fada2faeff53279 100644 (file)
@@ -16,6 +16,7 @@ use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
 use Org\Mxchange\CoreFramework\Database\Updateable;
 use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Response\Responseable;
@@ -109,7 +110,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda
         */
        public function outputConsoleTeaser () {
                // Get the app instance (for shortening our code)
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Output all lines
                self::createDebugInstance(__CLASS__)->debugOutput(' ');
index f58e327f5c85f354f75be0d8c097a5b6455be843..5eba09704a020bf76fbecb7de09079a526535aad 100644 (file)
@@ -9,6 +9,7 @@ use Org\Mxchange\City\Helper\CityHelper;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Handler\Task\HandleableTask;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Request\Requestable;
@@ -77,7 +78,7 @@ class SimulationDefaultCityDaemon extends BaseCityDaemon implements CityHelper,
         */
        public function addExtraCityFilters () {
                // Get the application instance from registry
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Get the controller from the application
                $controllerInstance = $applicationInstance->getControllerInstance();
index f523e58447ebe4eba442bd109de5f8309dcad9d2..b985a4aa829b6c1ecf524b9b3ef66f219fbfa161 100644 (file)
@@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand;
 use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Controller\Controller;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
@@ -75,7 +76,7 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get a registry and the application instance from it
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                /*
                 * ----------------------- Bootstrapping phase ------------------------
index 50b056694c83adc01a1d3d3f4a99d46f33bb3db8..ad4a9adbadc8aca5e273e765a87479999315e7fd 100644 (file)
@@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Controller\Controller;
 use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
@@ -74,7 +75,7 @@ class CityHtmlConfirmCommand extends BaseCommand implements Commandable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Prepare a template instance
                $templateInstance = $this->prepareTemplateInstance($applicationInstance);
index 70ae9d4ed16bbfb44e198adec4ae75d62174ebd0..335a7af4d953ee8adc0819f0464476ba1e060338 100644 (file)
@@ -6,6 +6,7 @@ namespace Org\Mxchange\City\Command;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Controller\Controller;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
@@ -96,7 +97,7 @@ class CityHtmlLoginAreaCommand extends BaseCommand implements Commandable {
                } // END - if
 
                // Get the application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Prepare a template instance
                $templateInstance = $this->prepareTemplateInstance($applicationInstance);
index 7446134ee316648724835083755bd623faa36f61..194ad83a354c13991be2b3ac7c892f2be75357d4 100644 (file)
@@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand;
 use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Controller\Controller;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Request\Requestable;
@@ -76,7 +77,7 @@ class CityHtmlLoginCommand extends BaseCommand implements Commandable, Registera
                GenericRegistry::getRegistry()->addInstance('extra', $this);
 
                // Get the application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Prepare a template instance
                $templateInstance = $this->prepareTemplateInstance($applicationInstance);
index ce21d184696184606d4985b6dcd0cf10cd6cd757..aad1e16470b5e56edad2e23594fe4271830d110c 100644 (file)
@@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand;
 use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Controller\Controller;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
@@ -72,7 +73,7 @@ class CityHtmlLoginFailedCommand extends BaseCommand implements Commandable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Prepare a template instance
                $templateInstance = $this->prepareTemplateInstance($applicationInstance);
index d9dac7ae98d0a3f0ab98d6ea1b1833c69d914380..598b7a12f0cfbacf8d011ec0ff671de717d3ba12 100644 (file)
@@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand;
 use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Controller\Controller;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
@@ -72,7 +73,7 @@ class CityHtmlLogoutDoneCommand extends BaseCommand implements Commandable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Prepare a template instance
                $templateInstance = $this->prepareTemplateInstance($applicationInstance);
index 5107e75d796a0d2f406262d5fb9ab9a9c5d24ad1..5e52149bba0bd9d30371d27decc93ddb523c650d 100644 (file)
@@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Controller\Controller;
 use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
@@ -76,7 +77,7 @@ class CityHtmlResendLinkCommand extends BaseCommand implements Commandable {
                $userInstance = GenericRegistry::getRegistry()->getInstance('user');
 
                // Get an application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Get a RNG instance (Random Number Generator)
                $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
index a44ae87954090b4f5ac177b0de6c4acae084be77..3bb123d045d042a758fa5615c26fee9cff3d65d8 100644 (file)
@@ -5,6 +5,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\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Response\Responseable;
@@ -78,7 +79,7 @@ class CityDaemonFactory extends ObjectFactory {
                        $cityInstance = ObjectFactory::createObjectByConfiguredName($configEntry, array($requestInstance));
 
                        // Get a registry
-                       $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+                       $applicationInstance = ApplicationHelper::getSelfInstance();
 
                        // Add city-specific filters
                        $cityInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
diff --git a/core b/core
index 196ab0fc031d6987c87e8c5d257c39f664ec9151..6e91754d589773df8bd3746008dd782133a48674 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 196ab0fc031d6987c87e8c5d257c39f664ec9151
+Subproject commit 6e91754d589773df8bd3746008dd782133a48674
index 818fb7386a86c0b9dec9db7fc259b495d9955c13..bc2faf43ddb258a277fbd85e2ab58b31c7660a05 100644 (file)
--- a/index.php
+++ b/index.php
@@ -57,12 +57,12 @@ final class ApplicationEntryPoint {
         * @return      void
         * @todo        This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
         */
-       public static final function exitApplication ($message = '', $code = false, $extraData = '', $silentMode = false) {
+       public static final function exitApplication (string $message = '', int $code = -1, string $extraData = '', bool $silentMode = false) {
                // Is this method already called?
                if (isset($GLOBALS['app_die_called'])) {
                        // Then output the text directly
                        exit($message);
-               } // END - if
+               }
 
                // This method shall not be called twice
                $GLOBALS['app_die_called'] = true;
@@ -71,7 +71,7 @@ final class ApplicationEntryPoint {
                if (empty($message)) {
                        // No message provided
                        $message = 'No message provided.';
-               } // END - if
+               }
 
                // Get config instance
                $configInstance = FrameworkBootstrap::getConfigurationInstance();
@@ -79,8 +79,8 @@ final class ApplicationEntryPoint {
                // Do we have debug installation?
                if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
                        // Abort here
-                       exit();
-               } // END - if
+                       exit;
+               }
 
                // Get some instances
                $tpl = $configInstance->getConfigEntry('html_template_class');
@@ -105,19 +105,18 @@ final class ApplicationEntryPoint {
                        }
 
                        // Get and prepare backtrace for output
-                       $backtraceArray = debug_backtrace();
                        $backtrace = '';
-                       foreach ($backtraceArray as $key => $trace) {
+                       foreach (debug_backtrace() as $key => $trace) {
                                // Set missing array elements
                                if (!isset($trace['file'])) {
                                        $trace['file'] = __FILE__;
-                               } // END - if
+                               }
                                if (!isset($trace['line'])) {
                                        $trace['line'] = __LINE__;
-                               } // END - if
+                               }
                                if (!isset($trace['args'])) {
                                        $trace['args'] = array();
-                               } // END - if
+                               }
 
                                // Add the traceback path to the final output
                                $backtrace .= sprintf('<span class="backtrace_file">%s</span>:%d, <span class="backtrace_function">%s(%d)</span><br />' . PHP_EOL,
@@ -126,7 +125,7 @@ final class ApplicationEntryPoint {
                                        $trace['function'],
                                        count($trace['args'])
                                );
-                       } // END - foreach
+                       }
 
                        // Init application instance
                        $applicationInstance = NULL;
@@ -138,7 +137,7 @@ final class ApplicationEntryPoint {
 
                                // Assign application data
                                $templateInstance->assignApplicationData();
-                       } // END - if
+                       }
 
                        // We only try this
                        try {
@@ -171,10 +170,10 @@ final class ApplicationEntryPoint {
                        }
 
                        // Good bye...
-                       exit();
+                       exit;
                } else {
                        // Output message and die
-                       exit(sprintf('[Main:] Emergency exit reached: <span class="emergency_span">%s</span>',
+                       die(sprintf('[Main:] Emergency exit reached: <span class="emergency_span">%s</span>',
                                $message
                        ));
                }
@@ -196,14 +195,12 @@ final class ApplicationEntryPoint {
                                // Create full path for testing
                                $realPath = realpath($possiblePath);
 
-                               // Debug message
-                               //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
-
                                // Is it false?
+                               //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
                                if ($realPath === false) {
                                        // Then, not found.
                                        continue;
-                               } // END - if
+                               }
 
                                // Append framework path
                                $frameworkPath = sprintf('%s%sframework%s', $realPath, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
@@ -211,25 +208,23 @@ final class ApplicationEntryPoint {
                                // First create full-qualified file name (FQFN) to framework/config-global.php
                                $configFile = $frameworkPath . 'config-global.php';
 
-                               // Debug message
-                               //* NOISY-DEBUG: */ printf('[%s:%d]: configFile=%s' . PHP_EOL, __METHOD__, __LINE__, $configFile);
-
                                // Is it readable?
+                               //* NOISY-DEBUG: */ printf('[%s:%d]: configFile=%s' . PHP_EOL, __METHOD__, __LINE__, $configFile);
                                if (is_readable($configFile)) {
                                        // Found one
                                        self::$frameworkPath = $frameworkPath;
 
                                        // Abort here
                                        break;
-                               } // END - if
-                       } // END - foreach
+                               }
+                       }
 
                        // Able to find?
                        if (!is_dir(self::$frameworkPath)) {
                                // Is no directory
                                throw new Exception('Cannot find framework.');
-                       } // END - if
-               } // END - if
+                       }
+               }
 
                // Return it
                return self::$frameworkPath;