]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/user/class_ShipSimuBaseUser.php
Moved database columns as constants in wrapper classes
[shipsimu.git] / application / ship-simu / main / user / class_ShipSimuBaseUser.php
index 96a107f666b881d7c0da4e95b01b34474bda2ded..5f61809a5451519e7ec93b6f3b23f6389db4b6f4 100644 (file)
@@ -40,18 +40,18 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
         */
        public function ifUserCreatedMaximumAllowedCompanies () {
                // Get max allowed companies to found
-               $maxFound = $this->getConfigInstance()->readConfig('max_allowed_companies_found');
+               $maxFound = $this->getConfigInstance()->getConfigEntry('max_allowed_companies_found');
 
                // Now get a search criteria and set the user's name as criteria
-               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-               $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
-               $criteriaInstance->setLimit($maxFound);
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+               $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+               $searchInstance->setLimit($maxFound);
 
                // Get a company wrapper
                $wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class');
 
                // Do the count-select by criteria
-               $totalRows = $wrapperInstance->doSelectCountByCriteria($criteriaInstance);
+               $totalRows = $wrapperInstance->doSelectCountByCriteria($searchInstance);
 
                // Does the user have reached maximum?
                $reached = ($totalRows >= $maxFound);
@@ -70,8 +70,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
                // Default is that everyone is poor... ;-)
                $hasRequired = false;
 
-               // Get a points instance from registry
-               $pointsInstance = Registry::getRegistry()->getInstance('points');
+               // Init instance
+               $pointsInstance = null;
+
+               try {
+                       // Get a points instance from registry
+                       $pointsInstance = Registry::getRegistry()->getInstance('points');
+               } catch (NullPointerException $e) {
+                       // Instance not found in registry
+                       // @TODO We should log this exception later
+               }
 
                // Is there an instance?
                if (is_null($pointsInstance)) {
@@ -98,8 +106,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
                // By default they want to help.
                $ifGovHelps = true;
 
-               // First get a government instance from registry
-               $governmentInstance = Registry::getRegistry()->getInstance('government');
+               // Init instance
+               $governmentInstance = null;
+
+               try {
+                       // First get a government instance from registry
+                       $governmentInstance = Registry::getRegistry()->getInstance('government');
+               } catch (NullPointerException $e) {
+                       // Instance not found in registry
+                       // @TODO We should log this exception later
+               }
 
                // Is it there?
                if (is_null($governmentInstance)) {
@@ -129,8 +145,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
                // By default they want to help.
                $ifGovHelps = true;
 
-               // First get a government instance from registry
-               $governmentInstance = Registry::getRegistry()->getInstance('government');
+               // Init instance
+               $governmentInstance = null;
+
+               try {
+                       // First get a government instance from registry
+                       $governmentInstance = Registry::getRegistry()->getInstance('government');
+               } catch (NullPointerException $e) {
+                       // Instance not found in registry
+                       // @TODO We should log this exception later
+               }
 
                // Is it there?
                if (is_null($governmentInstance)) {
@@ -161,8 +185,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
                // Per default the money bank cannot pay
                $bankLends = false;
 
-               // Get a money bank instance from registry
-               $bankInstance = Registry::getRegistry()->getInstance('money_bank');
+               // Init instance
+               $bankInstance = null;
+
+               try {
+                       // Get a money bank instance from registry
+                       $bankInstance = Registry::getRegistry()->getInstance('money_bank');
+               } catch (NullPointerException $e) {
+                       // Instance not found in registry
+                       // @TODO We should log this exception later
+               }
 
                // Is it there?
                if (is_null($bankInstance)) {
@@ -197,8 +229,16 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
                // For default he can still get money
                $hasMaxCredits = false;
 
-               // Get a money bank instance from registry
-               $bankInstance = Registry::getRegistry()->getInstance('money_bank');
+               // Init instance
+               $bankInstance = null;
+
+               try {
+                       // Get a money bank instance from registry
+                       $bankInstance = Registry::getRegistry()->getInstance('money_bank');
+               } catch (NullPointerException $e) {
+                       // Instance not found in registry
+                       // @TODO We should log this exception later
+               }
 
                // Is it there?
                if (is_null($bankInstance)) {