From: Roland Häder Date: Wed, 2 Dec 2020 00:47:27 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fea88c89d790fd1cc5101744e675a99db097d0a8;p=core.git Continued: - renamed database's "Wrapper" name part to "Frontend" - added trait for above instance getter/setter Signed-off-by: Roland Häder --- diff --git a/framework/config-global.php b/framework/config-global.php index bc964adf..2476e47e 100644 --- a/framework/config-global.php +++ b/framework/config-global.php @@ -233,10 +233,10 @@ $cfg->setConfigEntry('crypto_class', 'Org\Mxchange\CoreFramework\Helper\Crypto\C $cfg->setConfigEntry('rng_class', 'Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator'); // CFG: USER-DB-WRAPPER-CLASS -$cfg->setConfigEntry('user_db_wrapper_class', 'Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper'); +$cfg->setConfigEntry('user_db_frontend_class', 'Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend'); // CFG: NEWS-DB-WRAPPER-CLASS -$cfg->setConfigEntry('news_db_wrapper_class', 'Org\Mxchange\CoreFramework\Database\Frontend\News\NewsDatabaseWrapper'); +$cfg->setConfigEntry('news_db_frontend_class', 'Org\Mxchange\CoreFramework\Database\Frontend\News\NewsDatabaseFrontend'); // CFG: HTML-CMD-RESOLVER-CLASS $cfg->setConfigEntry('html_cmd_resolver_class', 'Org\Mxchange\CoreFramework\Resolver\Command\HtmlCommandResolver'); diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 15a9f5fb..e64f1241 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -5,9 +5,7 @@ namespace Org\Mxchange\CoreFramework\Object; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Criteria; -use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; -use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; @@ -60,18 +58,13 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac /** * Self-referencing instance */ - private static $instance = NULL; + private static $selfInstance = NULL; /** * The real class name */ private $realClass = __CLASS__; - /** - * An instance of a database wrapper class - */ - private $wrapperInstance = NULL; - /** * State instance */ @@ -209,13 +202,13 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac */ public final function __call (string $methodName, array $args = NULL) { // Set self-instance - self::$instance = $this; + self::$selfInstance = $this; // Call static method self::__callStatic($methodName, $args); // Clear self-instance - self::$instance = NULL; + self::$selfInstance = NULL; } /** @@ -224,7 +217,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @param $methodName Name of the missing method * @param $args Arguments passed to the method * @return void - * @throws InvalidArgumentException If self::$instance is not a framework's own object + * @throws InvalidArgumentException If self::$selfInstance is not a framework's own object */ public static final function __callStatic (string $methodName, array $args = NULL) { // Init argument string and class name @@ -233,12 +226,12 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac $className = 'unknown'; // Is self-instance set? - if (self::$instance instanceof FrameworkInterface) { + if (self::$selfInstance instanceof FrameworkInterface) { // Framework's own instance - $className = self::$instance->__toString(); - } elseif (!is_null(self::$instance)) { + $className = self::$selfInstance->__toString(); + } elseif (!is_null(self::$selfInstance)) { // Invalid argument! - throw new InvalidArgumentException(sprintf('self::instance[%s] is not expected.', gettype(self::$instance)), self::EXCEPTION_SELF_INSTANCE); + throw new InvalidArgumentException(sprintf('self::instance[%s] is not expected.', gettype(self::$selfInstance)), self::EXCEPTION_SELF_INSTANCE); } // Is it NULL, empty or an array? @@ -438,25 +431,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac return $webOutputInstance; } - /** - * Setter for DatabaseWrapper instance - * - * @param $wrapperInstance An instance of an DatabaseWrapper - * @return void - */ - public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) { - $this->wrapperInstance = $wrapperInstance; - } - - /** - * Getter for DatabaseWrapper instance - * - * @return $wrapperInstance An instance of an DatabaseWrapper - */ - public final function getWrapperInstance () { - return $this->wrapperInstance; - } - /** * Setter for state instance * diff --git a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php index f22cd9cf..e0ee64cf 100644 --- a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php +++ b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php @@ -7,7 +7,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -120,7 +120,7 @@ class HtmlConfirmCommand extends BaseCommand implements Commandable { } // Set username - $this->getTemplateInstance()->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME)); + $this->getTemplateInstance()->assignVariable('username', $userInstance->getField(UserDatabaseFrontend::DB_COLUMN_USERNAME)); // Construct the menu in every command. We could do this in BaseCommand class. But this means // *every* command has a navigation system and that is want we don't want. diff --git a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php index dd1aa58a..be32e26a 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php @@ -174,9 +174,6 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { * @return void */ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Default is no action - $actionInstance = NULL; - // Get registry $registryInstance = GenericRegistry::getRegistry(); diff --git a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php index 72e24a68..7ddcc8b4 100644 --- a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php +++ b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php @@ -7,7 +7,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; @@ -91,7 +91,7 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable { $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString)); // Update the user class - $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString); + $userInstance->updateDatabaseField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH, $hashedString); // Re-set config entry to mailer engine FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('html_template_class', FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('mail_template_class')); diff --git a/framework/main/classes/criteria/class_BaseCriteria.php b/framework/main/classes/criteria/class_BaseCriteria.php index c7aff1ed..e38926cf 100644 --- a/framework/main/classes/criteria/class_BaseCriteria.php +++ b/framework/main/classes/criteria/class_BaseCriteria.php @@ -32,9 +32,9 @@ use Org\Mxchange\CoreFramework\Utils\String\StringUtils; */ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { /** - * Wrapper class name stored in config entry + * Frontend class name stored in config entry */ - private $wrapperConfigEntry = ''; + private $frontendConfigEntry = ''; /** * Protected constructor @@ -106,22 +106,22 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { } /** - * Setter for wrapper class name + * Setter for frontend class name * - * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name + * @param $frontendConfigEntry Configuration entry which hold the frontend class' name * @return void */ - public final function setWrapperConfigEntry (string $wrapperConfigEntry) { - $this->wrapperConfigEntry = $wrapperConfigEntry; + public final function setFrontendConfigEntry (string $frontendConfigEntry) { + $this->frontendConfigEntry = $frontendConfigEntry; } /** - * Getter for wrapper class name + * Getter for frontend class name * - * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name + * @return $frontendConfigEntry Configuration entry which hold the frontend class' name */ - public final function getWrapperConfigEntry () { - return $this->wrapperConfigEntry; + public final function getFrontendConfigEntry () { + return $this->frontendConfigEntry; } /** diff --git a/framework/main/classes/database/backend/class_BaseDatabaseBackend.php b/framework/main/classes/database/backend/class_BaseDatabaseBackend.php new file mode 100644 index 00000000..a9305968 --- /dev/null +++ b/framework/main/classes/database/backend/class_BaseDatabaseBackend.php @@ -0,0 +1,103 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend { + // Constants for exceptions + const EXCEPTION_SQL_QUERY = 0x140; + + // Result array indexes + const RESULT_INDEX_ROWS = 'rows'; + const RESULT_INDEX_STATUS = 'status'; + const RESULT_INDEX_EXCEPTION = 'exception'; + + // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!) + const DB_CODE_TABLE_MISSING = 0x100; + const DB_CODE_TABLE_UNWRITEABLE = 0x101; + const DB_CODE_DATA_FILE_CORRUPT = 0x102; + + // Status results + const RESULT_OKAY = 'ok'; + + /** + * Last thrown exception or NULL if all is fine + */ + private $lastException = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct (string $className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for last exception + * + * @return $lastException Last thrown exception + */ + public final function getLastException () { + return $this->lastException; + } + + /** + * Setter for last exception + * + * @param $lastException Last thrown exception + * @return void + */ + public final function setLastException (FrameworkException $exceptionInstance) { + $this->lastException = $exceptionInstance; + } + + /** + * Reset the last exception instance. This should be done after a "query" + * was completed without any errors. + * + * @return void + */ + protected final function resetLastException () { + $this->lastException = NULL; + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public abstract function removeNonPublicDataFromArray (array $data); + +} diff --git a/framework/main/classes/database/class_BaseDatabaseBackend.php b/framework/main/classes/database/class_BaseDatabaseBackend.php deleted file mode 100644 index a9305968..00000000 --- a/framework/main/classes/database/class_BaseDatabaseBackend.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend { - // Constants for exceptions - const EXCEPTION_SQL_QUERY = 0x140; - - // Result array indexes - const RESULT_INDEX_ROWS = 'rows'; - const RESULT_INDEX_STATUS = 'status'; - const RESULT_INDEX_EXCEPTION = 'exception'; - - // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!) - const DB_CODE_TABLE_MISSING = 0x100; - const DB_CODE_TABLE_UNWRITEABLE = 0x101; - const DB_CODE_DATA_FILE_CORRUPT = 0x102; - - // Status results - const RESULT_OKAY = 'ok'; - - /** - * Last thrown exception or NULL if all is fine - */ - private $lastException = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct (string $className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for last exception - * - * @return $lastException Last thrown exception - */ - public final function getLastException () { - return $this->lastException; - } - - /** - * Setter for last exception - * - * @param $lastException Last thrown exception - * @return void - */ - public final function setLastException (FrameworkException $exceptionInstance) { - $this->lastException = $exceptionInstance; - } - - /** - * Reset the last exception instance. This should be done after a "query" - * was completed without any errors. - * - * @return void - */ - protected final function resetLastException () { - $this->lastException = NULL; - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public abstract function removeNonPublicDataFromArray (array $data); - -} diff --git a/framework/main/classes/database/class_BaseDatabaseWrapper.php b/framework/main/classes/database/class_BaseDatabaseWrapper.php deleted file mode 100644 index 13bf4e2e..00000000 --- a/framework/main/classes/database/class_BaseDatabaseWrapper.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseDatabaseWrapper extends BaseFrameworkSystem { - /** - * Cache instance - */ - private $cacheInstance = NULL; - - /** - * Current table name to use - */ - private $tableName = 'unknown'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct ($class) { - // Call parent constructor - parent::__construct($class); - - // Initialize the cache instance - $this->initCacheInstance(); - } - - /** - * Initializes the cache instance with a new object - * - * @return void - */ - private final function initCacheInstance () { - // Is the cache enabled? - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { - // Set the new instance - $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache(); - } // END - if - } - - /** - * Setter for table name - * - * @param $tableName Name of table name to set - * @return void - */ - protected final function setTableName ($tableName) { - $this->tableName = (string) $tableName; - } - - /** - * Getter for table name - * - * @return $tableName Name of table name to set - */ - protected final function getTableName () { - return $this->tableName; - } - - /** - * 'Inserts' a data set instance into a local file database folder - * - * @param $dataSetInstance A storeable data set - * @param $onlyKeys Only use these keys for a cache key - * @return void - */ - protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) { - // Default cache key is NULL - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys))); - $cacheKey = NULL; - - // Is cache enabled? - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { - // First get a key suitable for our cache and extend it with this class name - $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); - } // END - if - - // Does this key exists in cache? - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey)); - if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) { - // Purge the cache - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey)); - $this->cacheInstance->purgeOffset($cacheKey); - } // END - if - - // Handle it over to the middleware - FrameworkBootstrap::getDatabaseInstance()->queryInsertDataSet($dataSetInstance); - - // Trace message - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: EXIT!'); - } - - /** - * 'Updates' a data set instance with a database layer - * - * @param $dataSetInstance A storeable data set - * @param $onlyKeys Only use these keys for a cache key - * @return void - */ - protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) { - // Init cache key - $cacheKey = NULL; - - // Is cache enabled? - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { - // First get a key suitable for our cache and extend it with this class name - $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); - } // END - if - - // Does this key exists in cache? - if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) { - // Purge the cache - $this->cacheInstance->purgeOffset($cacheKey); - } // END - if - - // Handle it over to the middleware - FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); - } - - /** - * Getter for index key - * - * @return $indexKey Index key - */ - public final function getIndexKey () { - return FrameworkBootstrap::getDatabaseInstance()->getIndexKey(); - } - - /** - * Getter for last exception - * - * @return $lastException Last exception or NULL if none occured - */ - public final function getLastException () { - return FrameworkBootstrap::getDatabaseInstance()->getLastException(); - } - - /** - * Do a "select" query on the current table with the given search criteria and - * store it in cache for later usage - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $resultInstance An instance of a database result class - */ - public function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { - // Default cache key if cache is not enabled - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys))); - $cacheKey = NULL; - $result = []; - - // Is the cache enabled? - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { - // First get a key suitable for our cache and extend it with this class name - $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys); - } // END - if - - // Does this key exists in cache? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey)); - if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) { - // Then use this result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Cache used for cacheKey=%s', $cacheKey)); - $result = $this->cacheInstance->offsetGet($cacheKey); - } else { - // Now it's time to ask the database layer for this select statement - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Quering database, cacheKey=%s ...', $cacheKey)); - $result = FrameworkBootstrap::getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance); - - // Cache the result if not null - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[]=%s', gettype($result))); - if (!is_null($result)) { - // Is cache enabled? - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { - // A valid result has returned from the database layer - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result))); - $this->cacheInstance->offsetSet($cacheKey, $result); - } // END - if - } else { - // This invalid result must be wrapped - $result = array( - BaseDatabaseBackend::RESULT_INDEX_STATUS => 'invalid', - BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => FrameworkBootstrap::getDatabaseInstance()->getLastException() - ); - } - } - - // Create an instance of a CachedDatabaseResult class with the given result - // @TODO Minor: Update above comment to e.g. BaseDatabaseResult - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseBackend::RESULT_INDEX_STATUS, $result[BaseDatabaseBackend::RESULT_INDEX_STATUS], BaseDatabaseBackend::RESULT_INDEX_ROWS, isset($result[BaseDatabaseBackend::RESULT_INDEX_ROWS]), BaseDatabaseBackend::RESULT_INDEX_EXCEPTION, isset($result[BaseDatabaseBackend::RESULT_INDEX_EXCEPTION]))); - $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result)); - - // And return the instance - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: resultInstance=%s - EXIT!', $resultInstance->__toString())); - return $resultInstance; - } - - /** - * Count the numbers of rows we shall receive - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $numRows Numbers of rows of database entries - */ - public function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { - // Total numbers is -1 so we can distinglish between failed and valid queries - $numRows = 0; - - // Get the result from above method - $resultInstance = $this->doSelectByCriteria($criteriaInstance, $onlyKeys); - - // Was that query fine? - if ($resultInstance->ifStatusIsOkay()) { - // Then get the number of rows - $numRows = $resultInstance->getAffectedRows(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows); - } // END - if - - // Return the result - return $numRows; - } - - /** - * Getter for primary key used in wrapped table - * - * @return $primaryKey Primary key used in wrapped table - */ - public final function getPrimaryKeyValue () { - // Get the table name and a database instance and ask for it - $primaryKey = FrameworkBootstrap::getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName()); - - // Return value - return $primaryKey; - } - - /** - * Count rows of this table - * - * @return $count Count of total rows in this table - */ - public final function countTotalRows () { - // Get the table name and a database instance and ask for it - $count = FrameworkBootstrap::getDatabaseInstance()->countTotalRows($this->getTableName()); - - // Return value - return $count; - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public function removeNonPublicDataFromArray (array $data) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray(data) ...'); - $data = FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray($data); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data)); - return $data; - } - -} diff --git a/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php b/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php new file mode 100644 index 00000000..0a5aba8d --- /dev/null +++ b/framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php @@ -0,0 +1,297 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseDatabaseFrontend extends BaseFrameworkSystem { + /** + * Cache instance + */ + private $cacheInstance = NULL; + + /** + * Current table name to use + */ + private $tableName = 'unknown'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct ($class) { + // Call parent constructor + parent::__construct($class); + + // Initialize the cache instance + $this->initCacheInstance(); + } + + /** + * Initializes the cache instance with a new object + * + * @return void + */ + private final function initCacheInstance () { + // Is the cache enabled? + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { + // Set the new instance + $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache(); + } // END - if + } + + /** + * Setter for table name + * + * @param $tableName Name of table name to set + * @return void + */ + protected final function setTableName ($tableName) { + $this->tableName = (string) $tableName; + } + + /** + * Getter for table name + * + * @return $tableName Name of table name to set + */ + protected final function getTableName () { + return $this->tableName; + } + + /** + * 'Inserts' a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @param $onlyKeys Only use these keys for a cache key + * @return void + */ + protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) { + // Default cache key is NULL + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys))); + $cacheKey = NULL; + + // Is cache enabled? + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { + // First get a key suitable for our cache and extend it with this class name + $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); + } // END - if + + // Does this key exists in cache? + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey)); + if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) { + // Purge the cache + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey)); + $this->cacheInstance->purgeOffset($cacheKey); + } // END - if + + // Handle it over to the middleware + FrameworkBootstrap::getDatabaseInstance()->queryInsertDataSet($dataSetInstance); + + // Trace message + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: EXIT!'); + } + + /** + * 'Updates' a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @param $onlyKeys Only use these keys for a cache key + * @return void + */ + protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) { + // Init cache key + $cacheKey = NULL; + + // Is cache enabled? + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { + // First get a key suitable for our cache and extend it with this class name + $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); + } // END - if + + // Does this key exists in cache? + if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) { + // Purge the cache + $this->cacheInstance->purgeOffset($cacheKey); + } // END - if + + // Handle it over to the middleware + FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return FrameworkBootstrap::getDatabaseInstance()->getIndexKey(); + } + + /** + * Getter for last exception + * + * @return $lastException Last exception or NULL if none occured + */ + public final function getLastException () { + return FrameworkBootstrap::getDatabaseInstance()->getLastException(); + } + + /** + * Do a "select" query on the current table with the given search criteria and + * store it in cache for later usage + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $resultInstance An instance of a database result class + */ + public function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { + // Default cache key if cache is not enabled + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys))); + $cacheKey = NULL; + $result = []; + + // Is the cache enabled? + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { + // First get a key suitable for our cache and extend it with this class name + $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys); + } // END - if + + // Does this key exists in cache? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey)); + if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) { + // Then use this result + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Cache used for cacheKey=%s', $cacheKey)); + $result = $this->cacheInstance->offsetGet($cacheKey); + } else { + // Now it's time to ask the database layer for this select statement + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Quering database, cacheKey=%s ...', $cacheKey)); + $result = FrameworkBootstrap::getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance); + + // Cache the result if not null + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[]=%s', gettype($result))); + if (!is_null($result)) { + // Is cache enabled? + if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) { + // A valid result has returned from the database layer + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result))); + $this->cacheInstance->offsetSet($cacheKey, $result); + } // END - if + } else { + // This invalid result must be wrapped + $result = array( + BaseDatabaseBackend::RESULT_INDEX_STATUS => 'invalid', + BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => FrameworkBootstrap::getDatabaseInstance()->getLastException() + ); + } + } + + // Create an instance of a CachedDatabaseResult class with the given result + // @TODO Minor: Update above comment to e.g. BaseDatabaseResult + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseBackend::RESULT_INDEX_STATUS, $result[BaseDatabaseBackend::RESULT_INDEX_STATUS], BaseDatabaseBackend::RESULT_INDEX_ROWS, isset($result[BaseDatabaseBackend::RESULT_INDEX_ROWS]), BaseDatabaseBackend::RESULT_INDEX_EXCEPTION, isset($result[BaseDatabaseBackend::RESULT_INDEX_EXCEPTION]))); + $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result)); + + // And return the instance + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: resultInstance=%s - EXIT!', $resultInstance->__toString())); + return $resultInstance; + } + + /** + * Count the numbers of rows we shall receive + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $numRows Numbers of rows of database entries + */ + public function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) { + // Total numbers is -1 so we can distinglish between failed and valid queries + $numRows = 0; + + // Get the result from above method + $resultInstance = $this->doSelectByCriteria($criteriaInstance, $onlyKeys); + + // Was that query fine? + if ($resultInstance->ifStatusIsOkay()) { + // Then get the number of rows + $numRows = $resultInstance->getAffectedRows(); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows); + } // END - if + + // Return the result + return $numRows; + } + + /** + * Getter for primary key used in wrapped table + * + * @return $primaryKey Primary key used in wrapped table + */ + public final function getPrimaryKeyValue () { + // Get the table name and a database instance and ask for it + $primaryKey = FrameworkBootstrap::getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName()); + + // Return value + return $primaryKey; + } + + /** + * Count rows of this table + * + * @return $count Count of total rows in this table + */ + public final function countTotalRows () { + // Get the table name and a database instance and ask for it + $count = FrameworkBootstrap::getDatabaseInstance()->countTotalRows($this->getTableName()); + + // Return value + return $count; + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray (array $data) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray(data) ...'); + $data = FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray($data); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data)); + return $data; + } + +} diff --git a/framework/main/classes/database/frontend/class_NewsDatabaseWrapper.php b/framework/main/classes/database/frontend/class_NewsDatabaseWrapper.php deleted file mode 100644 index 8c879de6..00000000 --- a/framework/main/classes/database/frontend/class_NewsDatabaseWrapper.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Add missing own interface for public methods - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NewsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable { - // Constants for database table names - const DB_TABLE_NEWS = 'news'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createNewsDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new NewsDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_NEWS); - - // Return the instance - return $wrapperInstance; - } - -} diff --git a/framework/main/classes/database/frontend/class_PaymentsDatabaseWrapper.php b/framework/main/classes/database/frontend/class_PaymentsDatabaseWrapper.php deleted file mode 100644 index a1a7af7e..00000000 --- a/framework/main/classes/database/frontend/class_PaymentsDatabaseWrapper.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Add missing own interface for public methods - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PaymentsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable { - // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; - - // Constants for database table names - const DB_TABLE_PAYMENTS = 'payments'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createPaymentsDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new PaymentsDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_PAYMENTS); - - // Return the instance - return $wrapperInstance; - } - -} diff --git a/framework/main/classes/database/frontend/class_UserDatabaseWrapper.php b/framework/main/classes/database/frontend/class_UserDatabaseWrapper.php deleted file mode 100644 index f729abeb..00000000 --- a/framework/main/classes/database/frontend/class_UserDatabaseWrapper.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserDatabaseWrapper extends BaseDatabaseWrapper implements ManageableAccountWrapper, Registerable { - // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; - - // Constants for database columns - const DB_COLUMN_USERID = 'userid'; - const DB_COLUMN_USERNAME = 'username'; - const DB_COLUMN_EMAIL = 'email'; - const DB_COLUMN_CONFIRM_HASH = 'confirm_hash'; - const DB_COLUMN_USER_STATUS = 'user_status'; - - // Constants for database table names - const DB_TABLE_USER = 'user'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createUserDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new UserDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_USER); - - // Return the instance - return $wrapperInstance; - } - - /** - * Handles inserting the registration data from a registration instance into the database - * - * @param $registrationInstance An instance of a registration class - * @return void - */ - public function insertRegistrationObject (UserRegister $registrationInstance) { - // Generate a data set for the request - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); - - // Add registration elements to the dataset - $registrationInstance->addElementsToDataSet($dataSetInstance); - - // "Insert" this request instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - } - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a UpdateableResult class - * @return void - * @throws NullPointerException If $updateInstance or $searchInstance is null - */ - public function doUpdateByResult (UpdateableResult $resultInstance) { - // Get the search instance from result - $searchInstance = $resultInstance->getSearchInstance(); - - // Is this null? - if (is_null($searchInstance)) { - // Get the update instance - $updateInstance = $resultInstance->getUpdateInstance(); - - // Is this null? - if (is_null($updateInstance)) { - // Throw an exception here - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get search instance from update instance - $searchInstance = $updateInstance->getSearchInstance(); - - // Is it still null? - if (is_null($searchInstance)) { - // Throw an exception here - throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - } // END - if - - // Generate a data set object - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); - - // Add seach criteria - $dataSetInstance->setSearchInstance($searchInstance); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); - - // Add all update criteria to the database set - $resultInstance->addElementsToDataSet($dataSetInstance); - - // "Update" this request with the database - FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); - } - -} diff --git a/framework/main/classes/database/frontend/class_UserPointsDatabaseWrapper.php b/framework/main/classes/database/frontend/class_UserPointsDatabaseWrapper.php deleted file mode 100644 index 096cb90e..00000000 --- a/framework/main/classes/database/frontend/class_UserPointsDatabaseWrapper.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserPointsDatabaseWrapper extends BaseDatabaseWrapper implements BookablePointsWrapper, Registerable { - /** - * Constants for database table names - */ - const DB_TABLE_USER_POINTS = 'user_points'; - - /** - * Name of the user->points column - */ - const DB_COLUMN_POINTS_UID = 'points_uid'; - - /** - * Name of the points column - */ - const DB_COLUMN_POINTS = 'points'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createUserPointsDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new UserPointsDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_USER_POINTS); - - // Return the instance - return $wrapperInstance; - } - - /** - * Inserts the given points for the given user in the database - * - * @param $pointsInstance An instance of a user class - * @return void - */ - public function insertUserPoints (BookablePoints $pointsInstance) { - // Generate a data set for the request - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); - - // Add registration elements to the dataset - $pointsInstance->addElementsToDataSet($dataSetInstance); - - // "Insert" this request instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - } - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a UpdateableResult class - * @return void - */ - public function doUpdateByResult (UpdateableResult $resultInstance) { - // Generate a data set object - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); - - // Add all update criteria to the database set - $resultInstance->addElementsToDataSet($dataSetInstance); - - // Add seach criteria - $dataSetInstance->setSearchInstance($resultInstance->getUpdateInstance()->getSearchInstance()); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); - - // "Update" this request with the database - FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); - } - -} diff --git a/framework/main/classes/database/frontend/news/class_NewsDatabaseFrontend.php b/framework/main/classes/database/frontend/news/class_NewsDatabaseFrontend.php new file mode 100644 index 00000000..f99a5124 --- /dev/null +++ b/framework/main/classes/database/frontend/news/class_NewsDatabaseFrontend.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Add missing own interface for public methods + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NewsDatabaseFrontend extends BaseDatabaseFrontend implements Registerable { + // Constants for database table names + const DB_TABLE_NEWS = 'news'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database frontend by a provided user class + * + * @return $frontendInstance An instance of the created frontend class + */ + public static final function createNewsDatabaseFrontend () { + // Get a new instance + $frontendInstance = new NewsDatabaseFrontend(); + + // Set (primary!) table name + $frontendInstance->setTableName(self::DB_TABLE_NEWS); + + // Return the instance + return $frontendInstance; + } + +} diff --git a/framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php b/framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php new file mode 100644 index 00000000..215dbc69 --- /dev/null +++ b/framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Add missing own interface for public methods + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PaymentsDatabaseFrontend extends BaseDatabaseFrontend implements Registerable { + // Constants for exceptions + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; + + // Constants for database table names + const DB_TABLE_PAYMENTS = 'payments'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database frontend by a provided user class + * + * @return $frontendInstance An instance of the created frontend class + */ + public static final function createPaymentsDatabaseFrontend () { + // Get a new instance + $frontendInstance = new PaymentsDatabaseFrontend(); + + // Set (primary!) table name + $frontendInstance->setTableName(self::DB_TABLE_PAYMENTS); + + // Return the instance + return $frontendInstance; + } + +} diff --git a/framework/main/classes/database/frontend/user/class_UserDatabaseFrontend.php b/framework/main/classes/database/frontend/user/class_UserDatabaseFrontend.php new file mode 100644 index 00000000..99fcaee2 --- /dev/null +++ b/framework/main/classes/database/frontend/user/class_UserDatabaseFrontend.php @@ -0,0 +1,145 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserDatabaseFrontend extends BaseDatabaseFrontend implements ManageableAccountFrontend, Registerable { + // Constants for exceptions + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; + + // Constants for database columns + const DB_COLUMN_USERID = 'userid'; + const DB_COLUMN_USERNAME = 'username'; + const DB_COLUMN_EMAIL = 'email'; + const DB_COLUMN_CONFIRM_HASH = 'confirm_hash'; + const DB_COLUMN_USER_STATUS = 'user_status'; + + // Constants for database table names + const DB_TABLE_USER = 'user'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database frontend by a provided user class + * + * @return $frontendInstance An instance of the created frontend class + */ + public static final function createUserDatabaseFrontend () { + // Get a new instance + $frontendInstance = new UserDatabaseFrontend(); + + // Set (primary!) table name + $frontendInstance->setTableName(self::DB_TABLE_USER); + + // Return the instance + return $frontendInstance; + } + + /** + * Handles inserting the registration data from a registration instance into the database + * + * @param $registrationInstance An instance of a registration class + * @return void + */ + public function insertRegistrationObject (UserRegister $registrationInstance) { + // Generate a data set for the request + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); + + // Add registration elements to the dataset + $registrationInstance->addElementsToDataSet($dataSetInstance); + + // "Insert" this request instance completely into the database + $this->queryInsertDataSet($dataSetInstance); + } + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a UpdateableResult class + * @return void + * @throws NullPointerException If $updateInstance or $searchInstance is null + */ + public function doUpdateByResult (UpdateableResult $resultInstance) { + // Get the search instance from result + $searchInstance = $resultInstance->getSearchInstance(); + + // Is this null? + if (is_null($searchInstance)) { + // Get the update instance + $updateInstance = $resultInstance->getUpdateInstance(); + + // Is this null? + if (is_null($updateInstance)) { + // Throw an exception here + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get search instance from update instance + $searchInstance = $updateInstance->getSearchInstance(); + + // Is it still null? + if (is_null($searchInstance)) { + // Throw an exception here + throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + } // END - if + + // Generate a data set object + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); + + // Add seach criteria + $dataSetInstance->setSearchInstance($searchInstance); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); + + // Add all update criteria to the database set + $resultInstance->addElementsToDataSet($dataSetInstance); + + // "Update" this request with the database + FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + } + +} diff --git a/framework/main/classes/database/frontend/user_points/class_UserPointsDatabaseFrontend.php b/framework/main/classes/database/frontend/user_points/class_UserPointsDatabaseFrontend.php new file mode 100644 index 00000000..77f318ba --- /dev/null +++ b/framework/main/classes/database/frontend/user_points/class_UserPointsDatabaseFrontend.php @@ -0,0 +1,119 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserPointsDatabaseFrontend extends BaseDatabaseFrontend implements BookablePointsFrontend, Registerable { + /** + * Constants for database table names + */ + const DB_TABLE_USER_POINTS = 'user_points'; + + /** + * Name of the user->points column + */ + const DB_COLUMN_POINTS_UID = 'points_uid'; + + /** + * Name of the points column + */ + const DB_COLUMN_POINTS = 'points'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database frontend by a provided user class + * + * @return $frontendInstance An instance of the created frontend class + */ + public static final function createUserPointsDatabaseFrontend () { + // Get a new instance + $frontendInstance = new UserPointsDatabaseFrontend(); + + // Set (primary!) table name + $frontendInstance->setTableName(self::DB_TABLE_USER_POINTS); + + // Return the instance + return $frontendInstance; + } + + /** + * Inserts the given points for the given user in the database + * + * @param $pointsInstance An instance of a user class + * @return void + */ + public function insertUserPoints (BookablePoints $pointsInstance) { + // Generate a data set for the request + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); + + // Add registration elements to the dataset + $pointsInstance->addElementsToDataSet($dataSetInstance); + + // "Insert" this request instance completely into the database + $this->queryInsertDataSet($dataSetInstance); + } + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a UpdateableResult class + * @return void + */ + public function doUpdateByResult (UpdateableResult $resultInstance) { + // Generate a data set object + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); + + // Add all update criteria to the database set + $resultInstance->addElementsToDataSet($dataSetInstance); + + // Add seach criteria + $dataSetInstance->setSearchInstance($resultInstance->getUpdateInstance()->getSearchInstance()); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); + + // "Update" this request with the database + FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + } + +} diff --git a/framework/main/classes/database/result/class_CachedDatabaseResult.php b/framework/main/classes/database/result/class_CachedDatabaseResult.php index 9aca86df..56a6afcc 100644 --- a/framework/main/classes/database/result/class_CachedDatabaseResult.php +++ b/framework/main/classes/database/result/class_CachedDatabaseResult.php @@ -6,7 +6,7 @@ namespace Org\Mxchange\CoreFramework\Result\Database; use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria; use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; -use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend; use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult; @@ -416,13 +416,13 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * Solver for result index value with call-back method * * @param $databaseColumn Database column where the index might be found - * @param $wrapperInstance The wrapper instance to ask for array element + * @param $frontendInstance The frontend instance to ask for array element * @para $callBack Call-back object for setting the index; * 0=object instance,1=method name * @return void * @todo Find a caching way without modifying the result array */ - public function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack) { + public function solveResultIndex ($databaseColumn, DatabaseFrontend $frontendInstance, array $callBack) { // By default nothing is found $indexValue = 0; @@ -430,7 +430,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul if ($this->find($databaseColumn)) { // Use this value $indexValue = $this->getFoundValue(); - } elseif ($this->find($wrapperInstance->getIndexKey())) { + } elseif ($this->find($frontendInstance->getIndexKey())) { // Use this value $indexValue = $this->getFoundValue(); } diff --git a/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php b/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php index aaab6c22..0339a94d 100644 --- a/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php +++ b/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php @@ -5,7 +5,7 @@ namespace Org\Mxchange\CoreFramework\Discovery\Payment; // Import framework stuff use Org\Mxchange\CoreFramework\Discovery\BaseDiscovery; use Org\Mxchange\CoreFramework\Discovery\Discoverable; -use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; +use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate; @@ -81,11 +81,11 @@ class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Regis $criteriaInstance->addCriteria('payment_action', $this->getActionName() . '_action'); $criteriaInstance->setLimit(1); - // Get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('payment_db_wrapper_class'); + // Get a frontend instance + $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('payment_db_frontend_class'); // Get result back - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance); // Advanced to next entry and assert on it as it should always be there assert($resultInstance->valid()); diff --git a/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php b/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php new file mode 100644 index 00000000..8df8c285 --- /dev/null +++ b/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseFrontendFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton socket registry instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $frontendInstance A database frontend instance + */ + public static final function createFrontendByConfiguredName ($frontendName) { + // Get registry instance + $registryInstance = GenericRegistry::getRegistry(); + + // Do we have an instance in the registry? + if ($registryInstance->instanceExists($frontendName)) { + // Then use this instance + $frontendInstance = $registryInstance->getInstance($frontendName); + } else { + // Get the registry instance + $frontendInstance = self::createObjectByConfiguredName($frontendName); + + // Set the instance in registry for further use + $registryInstance->addInstance($frontendName, $frontendInstance); + } + + // Return the instance + return $frontendInstance; + } + +} diff --git a/framework/main/classes/factories/database/class_DatabaseWrapperFactory.php b/framework/main/classes/factories/database/class_DatabaseWrapperFactory.php deleted file mode 100644 index f64dd742..00000000 --- a/framework/main/classes/factories/database/class_DatabaseWrapperFactory.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DatabaseWrapperFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton socket registry instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $wrapperInstance A database wrapper instance - */ - public static final function createWrapperByConfiguredName ($wrapperName) { - // Get registry instance - $registryInstance = GenericRegistry::getRegistry(); - - // Do we have an instance in the registry? - if ($registryInstance->instanceExists($wrapperName)) { - // Then use this instance - $wrapperInstance = $registryInstance->getInstance($wrapperName); - } else { - // Get the registry instance - $wrapperInstance = self::createObjectByConfiguredName($wrapperName); - - // Set the instance in registry for further use - $registryInstance->addInstance($wrapperName, $wrapperInstance); - } - - // Return the instance - return $wrapperInstance; - } - -} diff --git a/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php b/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php index 1c41d370..6c346750 100644 --- a/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php +++ b/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Filter\User\Status; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Filter\BaseFilter; use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -72,10 +72,10 @@ class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable { $confirmed = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed'); // Update the user status to "confirmed" here - $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $confirmed); + $userInstance->updateDatabaseField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS, $confirmed); // Wipe out the confirm hash for extra security - $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, ''); + $userInstance->updateDatabaseField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH, ''); // Write all updates to the database die(__METHOD__ . ': REWRITE!' . PHP_EOL); diff --git a/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php b/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php index e832eb0c..35619274 100644 --- a/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -3,7 +3,7 @@ namespace Org\Mxchange\CoreFramework\Filter\Verifier\Confirmation; // Import framework stuff -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Filter\BaseFilter; use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException; use Org\Mxchange\CoreFramework\Filter\Filterable; @@ -94,7 +94,7 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable { $userInstance = GenericRegistry::getRegistry()->getInstance('user'); // Get the confirm code from user for comparison - $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH); + $userCode = $userInstance->getField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH); // Do we have the same code or different? if ($userCode != $confirmCode) { diff --git a/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php index 94acdfc5..c62a9eff 100644 --- a/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Filter\Verifier\User; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Factory\User\UserFactory; use Org\Mxchange\CoreFramework\Filter\BaseFilter; use Org\Mxchange\CoreFramework\Filter\Filterable; @@ -82,7 +82,7 @@ class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable { } // END - if // Is the user account confirmed? - if ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed')) { + if ($userInstance->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed')) { // Request is invalid! $requestInstance->requestIsValid(false); diff --git a/framework/main/classes/fuse/class_FrameworkFuseWrapper.php_discontinued b/framework/main/classes/fuse/class_FrameworkFuseWrapper.php_discontinued index 1c86c969..ff011978 100644 --- a/framework/main/classes/fuse/class_FrameworkFuseWrapper.php_discontinued +++ b/framework/main/classes/fuse/class_FrameworkFuseWrapper.php_discontinued @@ -1,6 +1,6 @@ getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed')); + $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed')); return $isUnconfirmed; } @@ -917,7 +917,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return $isUnconfirmed Whether the user account is locked */ public function ifUserAccountLocked () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_locked')); + $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_locked')); return $isUnconfirmed; } @@ -927,7 +927,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return $isUnconfirmed Whether the user account is a guest */ public function ifUserAccountGuest () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest')); + $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest')); return $isUnconfirmed; } diff --git a/framework/main/classes/points/class_UserPoints.php b/framework/main/classes/points/class_UserPoints.php index e26856ad..5370599b 100644 --- a/framework/main/classes/points/class_UserPoints.php +++ b/framework/main/classes/points/class_UserPoints.php @@ -5,7 +5,7 @@ namespace Org\Mxchange\CoreFramework\User\Points; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; -use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; +use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -72,14 +72,14 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add search criteria - $searchInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $userInstance->getUserId()); + $searchInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS_UID, $userInstance->getUserId()); $searchInstance->setLimit(1); - // Get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('user_points_db_wrapper_class'); + // Get a frontend instance + $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('user_points_db_frontend_class'); // Get result back - $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance); + $resultInstance = $frontendInstance->doSelectByCriteria($searchInstance); // Advance to first entry by default $resultInstance->next(); @@ -156,19 +156,19 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo $currentEntry = $this->getResultInstance()->current(); // Add the points - $amount += $currentEntry[UserPointsDatabaseWrapper::DB_COLUMN_POINTS]; + $amount += $currentEntry[UserPointsDatabaseFrontend::DB_COLUMN_POINTS]; // Now get another criteria $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); // And add our both entries - $updateInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $amount); + $updateInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS, $amount); // Add the search criteria for searching for the right entry $updateInstance->setSearchInstance($searchInstance); - // Set wrapper class name - $updateInstance->setWrapperConfigEntry('user_points_db_wrapper_class'); + // Set frontend class name + $updateInstance->setFrontendConfigEntry('user_points_db_frontend_class'); // Remember the update in database result $this->getResultInstance()->add2UpdateQueue($updateInstance); @@ -177,7 +177,7 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo $this->setAmount($amount); // Create the new entry - $wrapperInstance->insertUserPoints($this); + $frontendInstance->insertUserPoints($this); } } @@ -190,10 +190,10 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo */ public function addElementsToDataSet (StoreableCriteria $criteriaInstance) { // Add user id - $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $this->getUserInstance()->getUserId()); + $criteriaInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS_UID, $this->getUserInstance()->getUserId()); // Add amount - $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $this->getAmount()); + $criteriaInstance->addCriteria(UserPointsDatabaseFrontend::DB_COLUMN_POINTS, $this->getAmount()); } } diff --git a/framework/main/classes/reader/class_ConsoleNewsReader.php b/framework/main/classes/reader/class_ConsoleNewsReader.php index 0f19c0ae..d738aaa8 100644 --- a/framework/main/classes/reader/class_ConsoleNewsReader.php +++ b/framework/main/classes/reader/class_ConsoleNewsReader.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Reader\News\Console; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; -use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; +use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Reader\News\ReadableNews; @@ -72,8 +72,8 @@ class ConsoleNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg // Get 'command' for saving some calls $command = FrameworkBootstrap::getRequestInstance()->getRequestElement('command'); - // First get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class'); + // First get a frontend instance + $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('news_db_frontend_class'); // Next create a searchable criteria instance $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); @@ -85,7 +85,7 @@ class ConsoleNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit'); // Get a resultInstance back from the database - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance); // Save that resultInstance in this class $this->setResultInstance($resultInstance); diff --git a/framework/main/classes/reader/class_DefaultNewsReader.php b/framework/main/classes/reader/class_DefaultNewsReader.php index 8d67d32e..d17a7fe9 100644 --- a/framework/main/classes/reader/class_DefaultNewsReader.php +++ b/framework/main/classes/reader/class_DefaultNewsReader.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Reader\News; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; -use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; +use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -71,8 +71,8 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg // Get 'command' for saving some calls $command = FrameworkBootstrap::getRequestInstance()->getRequestElement('command'); - // First get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class'); + // First get a frontend instance + $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('news_db_frontend_class'); // Next create a searchable criteria instance $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); @@ -84,7 +84,7 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit'); // Get a resultInstance back from the database - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance); // Save that resultInstance in this class $this->setResultInstance($resultInstance); diff --git a/framework/main/classes/user/class_BaseUser.php b/framework/main/classes/user/class_BaseUser.php index f3da469e..1a2da22e 100644 --- a/framework/main/classes/user/class_BaseUser.php +++ b/framework/main/classes/user/class_BaseUser.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\User; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Database\Updateable; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; @@ -139,21 +139,21 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { // Is a previous result there? if (!$this->getResultInstance() instanceof SearchableResult) { - // Get a UserDatabaseWrapper instance - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + // Get a UserDatabaseFrontend instance + $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class'); // Create a search criteria $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add the username as a criteria and set limit to one entry - $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName()); $criteriaInstance->setLimit(1); // Get a search result - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance); // Set the index "solver" - $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + $resultInstance->solveResultIndex(UserDatabaseFrontend::DB_COLUMN_USERID, $frontendInstance, array($this, 'setUserId')); // And finally set it $this->setResultInstance($resultInstance); @@ -183,21 +183,21 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { // Is a previous result there? if (!$this->getResultInstance() instanceof SearchableResult) { - // Get a UserDatabaseWrapper instance - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + // Get a UserDatabaseFrontend instance + $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class'); // Create a search criteria $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add the username as a criteria and set limit to one entry - $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail()); + $criteriaInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_EMAIL, $this->getEmail()); $criteriaInstance->setLimit(1); // Get a search result - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance); // Set the index "solver" - $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + $resultInstance->solveResultIndex(UserDatabaseFrontend::DB_COLUMN_USERID, $frontendInstance, array($this, 'setUserId')); // And finally set it $this->setResultInstance($resultInstance); @@ -238,21 +238,21 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { // Is a previous result there? if ((!$this->getResultInstance() instanceof SearchableResult) || ($this->getResultInstance()->count() == 0)) { - // Get a UserDatabaseWrapper instance - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + // Get a UserDatabaseFrontend instance + $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class'); // Create a search criteria $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add the username as a criteria and set limit to one entry - $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName()); $criteriaInstance->setLimit(1); // Get a search result - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + $resultInstance = $frontendInstance->doSelectByCriteria($criteriaInstance); // Set the index "solver" - $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + $resultInstance->solveResultIndex(UserDatabaseFrontend::DB_COLUMN_USERID, $frontendInstance, array($this, 'setUserId')); // And finally set it $this->setResultInstance($resultInstance); @@ -303,11 +303,11 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { * @return $primaryValue Value of the primary key based on database type */ public final function getPrimaryKey () { - // Get a user database wrapper - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + // Get a user database frontend + $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class'); - // Get the primary key back from the wrapper - $primaryKey = $wrapperInstance->getPrimaryKeyValue(); + // Get the primary key back from the frontend + $primaryKey = $frontendInstance->getPrimaryKeyValue(); // Get that field $primaryValue = $this->getField($primaryKey); @@ -329,7 +329,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { $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 @@ -341,8 +341,8 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { // 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); @@ -355,7 +355,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { */ public function isConfirmed () { // Determine it - $isConfirmed = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed')); + $isConfirmed = ($this->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed')); // Return it return $isConfirmed; @@ -368,7 +368,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { */ public function isGuest () { // Determine it - $isGuest = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest')); + $isGuest = ($this->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest')); // Return it return $isGuest; diff --git a/framework/main/classes/user/member/class_Member.php b/framework/main/classes/user/member/class_Member.php index 07449e68..f3e204b2 100644 --- a/framework/main/classes/user/member/class_Member.php +++ b/framework/main/classes/user/member/class_Member.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\User\Login; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -138,7 +138,7 @@ class Member extends BaseUser implements ManageableMember, Registerable { $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 @@ -151,8 +151,8 @@ class Member extends BaseUser implements ManageableMember, Registerable { // 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); diff --git a/framework/main/exceptions/user/class_UserNoGuestException.php b/framework/main/exceptions/user/class_UserNoGuestException.php index 7f1f5121..017a9967 100644 --- a/framework/main/exceptions/user/class_UserNoGuestException.php +++ b/framework/main/exceptions/user/class_UserNoGuestException.php @@ -3,7 +3,7 @@ namespace Org\Mxchange\CoreFramework\Deprecated; // Import framework stuff -use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Generic\FrameworkException; /** @@ -43,7 +43,7 @@ class UserNoGuestException extends FrameworkException { $messageArray[0]->__toString(), $this->getLine(), $messageArray[1], - $messageArray[0]->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) + $messageArray[0]->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) ); // Make sure everything is assigned properly diff --git a/framework/main/interfaces/criteria/class_Criteria.php b/framework/main/interfaces/criteria/class_Criteria.php index 964d6394..8cbc0b91 100644 --- a/framework/main/interfaces/criteria/class_Criteria.php +++ b/framework/main/interfaces/criteria/class_Criteria.php @@ -29,19 +29,19 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; */ interface Criteria extends FrameworkInterface { /** - * Setter for wrapper class name + * Setter for frontend class name * - * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name + * @param $frontendConfigEntry Configuration entry which hold the frontend class' name * @return void */ - function setWrapperConfigEntry (string $wrapperConfigEntry); + function setFrontendConfigEntry (string $frontendConfigEntry); /** - * Getter for wrapper class name + * Getter for Frontend class name * - * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name + * @return $frontendConfigEntry Configuration entry which hold the Frontend class' name */ - function getWrapperConfigEntry (); + function getFrontendConfigEntry (); /** * Checks whether given key is set diff --git a/framework/main/interfaces/database/class_DatabaseWrapper.php b/framework/main/interfaces/database/class_DatabaseWrapper.php deleted file mode 100644 index 87352f00..00000000 --- a/framework/main/interfaces/database/class_DatabaseWrapper.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface DatabaseWrapper extends FrameworkInterface { - /** - * Getter for index key - * - * @return $indexKey Index key - */ - function getIndexKey(); - - /** - * Getter for last exception - * - * @return $lastException Last exception or NULL if none occured - */ - function getLastException(); - - /** - * Do a "select" query on the current table with the given search criteria and - * store it in cache for later usage - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $resultInstance An instance of a database result class - */ - function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = []); - - /** - * Count the numbers of rows we shall receive - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $numRows Numbers of rows of database entries - */ - function doSelectCountByCriteria(Criteria $criteriaInstance, array $onlyKeys = []); - - /** - * Getter for primary key used in wrapped table - * - * @return $primaryKey Primary key used in wrapped table - */ - function getPrimaryKeyValue(); - - /** - * Counts total rows of this table - * - * @return $count Total rows of this table - */ - function countTotalRows(); - -} diff --git a/framework/main/interfaces/database/frontend/account/class_ManageableAccountFrontend.php b/framework/main/interfaces/database/frontend/account/class_ManageableAccountFrontend.php new file mode 100644 index 00000000..af1e5bd2 --- /dev/null +++ b/framework/main/interfaces/database/frontend/account/class_ManageableAccountFrontend.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableAccountFrontend extends DatabaseFrontend { + /** + * Handles inserting the registration data from a registration instance into the database + * + * @param $registrationInstance An instance of a registration class + * @return void + */ + function insertRegistrationObject (UserRegister $registrationInstance); + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a UpdateableResult class + * @return void + */ + function doUpdateByResult (UpdateableResult $resultInstance); + +} diff --git a/framework/main/interfaces/database/frontend/class_DatabaseFrontend.php b/framework/main/interfaces/database/frontend/class_DatabaseFrontend.php new file mode 100644 index 00000000..d37cbf25 --- /dev/null +++ b/framework/main/interfaces/database/frontend/class_DatabaseFrontend.php @@ -0,0 +1,79 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DatabaseFrontend extends FrameworkInterface { + /** + * Getter for index key + * + * @return $indexKey Index key + */ + function getIndexKey(); + + /** + * Getter for last exception + * + * @return $lastException Last exception or NULL if none occured + */ + function getLastException(); + + /** + * Do a "select" query on the current table with the given search criteria and + * store it in cache for later usage + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $resultInstance An instance of a database result class + */ + function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = []); + + /** + * Count the numbers of rows we shall receive + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $numRows Numbers of rows of database entries + */ + function doSelectCountByCriteria(Criteria $criteriaInstance, array $onlyKeys = []); + + /** + * Getter for primary key used in wrapped table + * + * @return $primaryKey Primary key used in wrapped table + */ + function getPrimaryKeyValue(); + + /** + * Counts total rows of this table + * + * @return $count Total rows of this table + */ + function countTotalRows(); + +} diff --git a/framework/main/interfaces/database/frontend/user_points/class_BookablePointsFrontend.php b/framework/main/interfaces/database/frontend/user_points/class_BookablePointsFrontend.php new file mode 100644 index 00000000..de54acdd --- /dev/null +++ b/framework/main/interfaces/database/frontend/user_points/class_BookablePointsFrontend.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface BookablePointsFrontend extends DatabaseFrontend { + /** + * Inserts the given points for the given user in the database + * + * @param $pointsInstance An instance of a user class + * @return void + */ + function insertUserPoints (BookablePoints $pointsInstance); + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a UpdateableResult class + * @return void + */ + function doUpdateByResult (UpdateableResult $resultInstance); + +} diff --git a/framework/main/interfaces/database/wrapper/class_BookablePointsWrapper.php b/framework/main/interfaces/database/wrapper/class_BookablePointsWrapper.php deleted file mode 100644 index a1c65263..00000000 --- a/framework/main/interfaces/database/wrapper/class_BookablePointsWrapper.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface BookablePointsWrapper extends DatabaseWrapper { - /** - * Inserts the given points for the given user in the database - * - * @param $pointsInstance An instance of a user class - * @return void - */ - function insertUserPoints (BookablePoints $pointsInstance); - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a UpdateableResult class - * @return void - */ - function doUpdateByResult (UpdateableResult $resultInstance); - -} diff --git a/framework/main/interfaces/database/wrapper/class_ManageableAccountWrapper.php b/framework/main/interfaces/database/wrapper/class_ManageableAccountWrapper.php deleted file mode 100644 index e22a5c5b..00000000 --- a/framework/main/interfaces/database/wrapper/class_ManageableAccountWrapper.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ManageableAccountWrapper extends DatabaseWrapper { - /** - * Handles inserting the registration data from a registration instance into the database - * - * @param $registrationInstance An instance of a registration class - * @return void - */ - function insertRegistrationObject (UserRegister $registrationInstance); - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a UpdateableResult class - * @return void - */ - function doUpdateByResult (UpdateableResult $resultInstance); - -} diff --git a/framework/main/interfaces/result/class_SearchableResult.php b/framework/main/interfaces/result/class_SearchableResult.php index 03c846da..d0925cc5 100644 --- a/framework/main/interfaces/result/class_SearchableResult.php +++ b/framework/main/interfaces/result/class_SearchableResult.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Result\Search; // Import framework stuff use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria; -use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; /** @@ -45,6 +45,6 @@ interface SearchableResult extends FrameworkInterface { * @para $callBack Call-back object for setting the index * @return void */ - function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack); + function solveResultIndex ($databaseColumn, DatabaseFrontend $frontendInstance, array $callBack); } diff --git a/framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php b/framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php new file mode 100644 index 00000000..9ac1ecd5 --- /dev/null +++ b/framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php @@ -0,0 +1,55 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +trait DatabaseFrontendTrait { + /** + * An instance of a DatabaseFrontend class + */ + private $frontendInstance = NULL; + + /** + * Setter for DatabaseFrontend instance + * + * @param $frontendInstance An instance of a DatabaseFrontend class + * @return void + */ + public final function setFrontendInstance (DatabaseFrontend $frontendInstance) { + $this->frontendInstance = $frontendInstance; + } + + /** + * Getter for DatabaseFrontend instance + * + * @return $frontendInstance An instance of a DatabaseFrontend class + */ + public final function getFrontendInstance () { + return $this->frontendInstance; + } + +}