// 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\ObjectFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Traits\Manager\Account\ManageableAccountTrait;
+use Org\Mxchange\CoreFramework\Traits\Result\Search\SearchableResultTrait;
use Org\Mxchange\CoreFramework\User\ManageableAccount;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePoints {
+ // Load traits
+ use ManageableAccountTrait;
+ use SearchableResultTrait;
+
/**
* Amount of points
*/
*
* @return void
*/
- protected function __construct () {
+ private function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
}
$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();
$this->getResultInstance()->rewind();
// Do we have an entry?
- if ($this->getResultInstance()->next()) {
+ if ($this->getResultInstance()->valid()) {
// Get the entry
$currEntry = $this->getResultInstance()->current();
// Has he enought points?
$hasRequired = ($currEntry['points'] >= $requiredPoints);
- } // END - if
+ }
// Return the result
return $hasRequired;
$this->getResultInstance()->rewind();
// Do we have an entry?
- if ($this->getResultInstance()->next()) {
+ if ($this->getResultInstance()->valid()) {
// Get the entry
- $entry = $this->getResultInstance()->current();
+ $currentEntry = $this->getResultInstance()->current();
// Add the points
- $amount += $entry[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);
$this->setAmount($amount);
// Create the new entry
- $wrapperInstance->insertUserPoints($this);
+ $frontendInstance->insertUserPoints($this);
}
}
*/
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());
}
}