]> git.mxchange.org Git - city.git/blobdiff - application/city/classes/commands/console/class_CityConsoleDaemonCommand.php
Continued:
[city.git] / application / city / classes / commands / console / class_CityConsoleDaemonCommand.php
index de4e495e54690f52b3d25689c5fae7ac88510c57..b399a60487fddf56c9951d38b5ab487352190b05 100644 (file)
@@ -1,10 +1,27 @@
 <?php
+// Own namespace
+namespace Org\Mxchange\City\Command;
+
+// Import application-specific stuff
+use Org\Mxchange\Factory\City\Daemon\CityDaemonFactory;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Command\BaseCommand;
+use Org\Mxchange\CoreFramework\Command\Commandable;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+
 /**
  * A command for the 'daemon' routine
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2015, 2016 City Developer Team
+ * @copyright  Copyright (c) 2015 - 2023 City Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -59,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 = Registry::getRegistry()->getInstance('app');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                /*
                 * ----------------------- Bootstrapping phase ------------------------
@@ -67,9 +84,9 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable {
                 * extra arguments which mostly override config entries or enable special
                 * features within the hub (none is ready at this development stage)
                 */
-               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('BOOTSTRAP: Beginning with bootstrap...');
                $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
-               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('BOOTSTRAP: Bootstrap finished.');
 
                // Get city instance
                $cityInstance = CityDaemonFactory::createCityDaemonInstance();
@@ -85,10 +102,10 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable {
                $cityInstance->activateCityDaemon($requestInstance, $responseInstance);
 
                // Get task handler instance
-               $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
+               $handlerInstance = ObjectRegistry::getRegistry('generic')->getInstance('task_handler');
 
                // Debug message
-               self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Entering main loop. ---');
 
                /*
                 * ----------------------------- Main loop ----------------------------
@@ -99,10 +116,10 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable {
                while (($cityInstance->isCityActive()) && ($handlerInstance->hasTasksLeft())) {
                        // Handle all tasks here
                        $handlerInstance->handleTasks();
-               } // END - while
+               }
 
                // Debug message
-               self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Leaving main loop. ---');
        }
 
        /**
@@ -115,21 +132,21 @@ class CityConsoleDaemonCommand extends BaseCommand implements Commandable {
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Add pre filters
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_php_requirements_filter'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_initializer_filter'));
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_welcome_teaser_filter'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_php_requirements_filter_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_initializer_filter_class'));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_welcome_teaser_filter_class'));
 
                // Add bootstrap filters
-               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_init_daemon_filter'));
-               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_extra_bootstrapping_filter'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_init_daemon_filter_class'));
+               $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_bootstrap_extra_bootstrapping_filter_class'));
 
                // Add city activation filters
-               $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_activation_task_handler_initializer_filter'));
+               $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_activation_task_handler_initializer_filter_class'));
 
                // Add shutdown filters, you may want to shutdown the task handler as last one.
-               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_task_handler_filter'));
+               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_task_handler_filter_class'));
 
                // This is the last generic shutdown filter
-               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_city_filter'));
+               $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('city_daemon_shutdown_city_filter_class'));
        }
 }