X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fcity%2Fclasses%2Fcity_daemon%2Fclass_BaseCityDaemon.php;h=90e59b147bc1cdada7dd046606952e97b999592a;hb=c9f10d588a76dc68f9d293e69548ba740119b8a2;hp=3543c393d2cf3b7bca3c313ffc7f4ec227e17569;hpb=3dc4c471c90f14f68b91297b8f17012b5f755374;p=city.git diff --git a/application/city/classes/city_daemon/class_BaseCityDaemon.php b/application/city/classes/city_daemon/class_BaseCityDaemon.php index 3543c39..90e59b1 100644 --- a/application/city/classes/city_daemon/class_BaseCityDaemon.php +++ b/application/city/classes/city_daemon/class_BaseCityDaemon.php @@ -6,25 +6,31 @@ namespace Org\Mxchange\City\Daemon; use Org\Mxchange\City\Factory\Manager\ManagerFactory; use Org\Mxchange\City\Factory\State\CityStateFactory; use Org\Mxchange\City\Generic\BaseCitySystem; -use Org\Mxchange\City\Database\Frontend\Information\CityInformationDatabaseWrapper; +use Org\Mxchange\City\Database\Frontend\Information\CityInformationDatabaseFrontend; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Add\AddableCriteria; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Database\Updateable; -use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; -use Org\Mxchange\CoreFramework\Factory\ObjectFactory; -use Org\Mxchange\CoreFramework\Registry\Registry; +use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory; +use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; +use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware; +use Org\Mxchange\CoreFramework\Registry\GenericRegistry;; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Response\Responseable; +use Org\Mxchange\CoreFramework\Traits\Crypto\CryptoTrait; +use Org\Mxchange\CoreFramework\Traits\Database\Frontend\DatabaseFrontendTrait; +use Org\Mxchange\CoreFramework\Traits\State\StateableTrait; /** * A general City class * * @author Roland Haeder * @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 * @@ -42,6 +48,11 @@ use Org\Mxchange\CoreFramework\Response\Responseable; * along with this program. If not, see . */ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, AddableCriteria { + // Load traits + use CryptoTrait; + use DatabaseFrontendTrait; + use StateableTrait; + /** * City types */ @@ -59,15 +70,15 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda * @param $className Name of the class * @return void */ - protected function __construct ($className) { + protected function __construct (string $className) { // Call parent constructor parent::__construct($className); - // Get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('city_info_db_wrapper_class'); + // Get a frontend instance + $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('city_info_db_frontend_class'); // Set it here - $this->setWrapperInstance($wrapperInstance); + $this->setFrontendInstance($frontendInstance); // Get a crypto instance $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); @@ -76,7 +87,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda $this->setCryptoInstance($cryptoInstance); // Add own instance to registry - Registry::getRegistry()->addInstance('city', $this); + GenericRegistry::getRegistry()->addInstance('city', $this); // Init state which sets the state to 'init' $this->initState(); @@ -100,12 +111,12 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda */ public function outputConsoleTeaser () { // Get the app instance (for shortening our code) - $app = $this->getApplicationInstance(); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Output all lines self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . FrameworkBootstrap::getRequestInstance()->getRequestElement('mode') . ' daemon starting'); - self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2015, 2016 City Developer Team'); + self::createDebugInstance(__CLASS__)->debugOutput($applicationInstance->getAppName() . ' v' . $applicationInstance->getAppVersion() . ' - ' . FrameworkBootstrap::getRequestInstance()->getRequestElement('mode') . ' daemon starting'); + self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2015 - 2023 City Developer Team'); self::createDebugInstance(__CLASS__)->debugOutput(' '); self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); @@ -125,11 +136,11 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda assert($requestInstance instanceof Requestable); // Add City number and type - $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID , 1); - $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_MODE, $requestInstance->getRequestElement('mode')); + $criteriaInstance->addCriteria(CityInformationDatabaseFrontend::DB_COLUMN_CITY_ID , 1); + $criteriaInstance->addCriteria(CityInformationDatabaseFrontend::DB_COLUMN_CITY_MODE, $requestInstance->getRequestElement('mode')); // Add the City id - $criteriaInstance->addCriteria(CityInformationDatabaseWrapper::DB_COLUMN_CITY_ID, $this->getCityId()); + $criteriaInstance->addCriteria(CityInformationDatabaseFrontend::DB_COLUMN_CITY_ID, $this->getCityId()); } /** @@ -143,14 +154,14 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda */ public function updateDatabaseField ($fieldName, $fieldValue) { // Unfinished - $this->partialStub('Unfinished: fieldName=' . $fieldName . ',fieldValue=' . $fieldValue); + DebugMiddleware::getSelfInstance()->partialStub('Unfinished: fieldName=' . $fieldName . ',fieldValue=' . $fieldValue); return; // Get a critieria instance $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add search criteria - $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $searchInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName()); $searchInstance->setLimit(1); // Now get another criteria @@ -162,8 +173,8 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda // Add the search criteria for searching for the right entry $updateInstance->setSearchInstance($searchInstance); - // Set wrapper class name - $updateInstance->setWrapperConfigEntry('user_db_wrapper_class'); + // Set frontend class name + $updateInstance->setFrontendConfigEntry('user_db_frontend_class'); // Remember the update in database result $this->getResultInstance()->add2UpdateQueue($updateInstance); @@ -179,7 +190,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda */ public function activateCityDaemon (Requestable $requestInstance, Responseable $responseInstance) { // Get the controller here - $controllerInstance = Registry::getRegistry()->getInstance('controller'); + $controllerInstance = GenericRegistry::getRegistry()->getInstance('controller'); // Run all filters for the City activation $controllerInstance->executeActivationFilters($requestInstance, $responseInstance); @@ -221,7 +232,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()); } /** @@ -233,7 +244,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $cityData) { // Add all data the array provides - foreach (CityInformationDatabaseWrapper::getAllElements() as $element) { + foreach (CityInformationDatabaseFrontend::getAllElements() as $element) { // Is the element there? if (isset($cityData[$element])) { // Add it @@ -242,7 +253,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda // Output warning message /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in CityData array.'); } - } // END - foreac + } } /** @@ -252,7 +263,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda * @todo 0% done */ public function bootstrapInitCityDaemon () { - $this->partialStub('Please add something here.'); + DebugMiddleware::getSelfInstance()->partialStub('Please add something here.'); } /** @@ -267,7 +278,7 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda $sectionsInstance = ManagerFactory::createManagerByType('city_sections'); // Call it's method and return value - return $sectionsInstance->isMapPendingExpansion(); + return $sectionsInstance->isSectionPendingExpansion(); } /** @@ -282,4 +293,5 @@ abstract class BaseCityDaemon extends BaseCitySystem implements Updateable, Adda // Call it's method and return value $sectionsInstance->expandMaps(); } + }