]> git.mxchange.org Git - hub.git/commitdiff
Instance 'miner' is now added to registry in BaseHubMiner.
authorRoland Haeder <roland@mxchange.org>
Mon, 11 May 2015 22:13:23 +0000 (00:13 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 11 May 2015 22:13:23 +0000 (00:13 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/factories/states/miner/class_MinerStateFactory.php
application/hub/main/filter/miner/class_MinerInitializationFilter.php
application/hub/main/miner/class_BaseHubMiner.php

index b947915c54868e0addfeadc6093c884783ceebde..2b2a7e02f034dcb9d6906c766a0cd52d66fcc570 100644 (file)
@@ -37,15 +37,17 @@ class MinerStateFactory extends ObjectFactory {
         * given miner instance.
         *
         * @param       $stateName              Name of the state
-        * @param       $minerInstance  A MinerHelper class instance
         * @return      $stateInstance  A Stateable class instance
         */
-       public static final function createMinerStateInstanceByName ($stateName, MinerHelper $minerInstance) {
+       public static final function createMinerStateInstanceByName ($stateName) {
                // Then construct the class' configuraton entry
                $className = 'miner_' . $stateName . '_state_class';
 
+               // Get miner instance
+               $minerInstance = Registry::getRegistry()->getInstance('miner');
+
                // Get a class from that configuration entry
-               $stateInstance = self::createObjectByConfiguredName($className, array($minerInstance));
+               $stateInstance = self::createObjectByConfiguredName($className);
 
                // Debug message
                self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Miner state has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
index 5785e5b95a788cc56870998ff3bcb693495d0a42..bf922d51fe50363e08763b28e0ddafc1a5810d2b 100644 (file)
@@ -87,9 +87,6 @@ class MinerInitializationFilter extends BaseMinerFilter implements Filterable {
                        // @TODO Can we rewrite this to app_exit() ?
                        $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']:  miner mode ' . $minerMode . ' is invalid.');
                }
-
-               // Set the miner instance in registry
-               Registry::getRegistry()->addInstance('miner', $minerInstance);
        }
 }
 
index eee201c95d78824ebe8a04eedc8fbbd4a8969f12..8bbc29fa67bbcf7afde4d69c581c90794ce5a88b 100644 (file)
@@ -67,6 +67,9 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable {
         * @return      void
         */
        private function initMiner () {
+               // Add own instance to registry
+               Registry::getRegistry()->addInstance('miner', $this);
+
                // Init the state
                MinerStateFactory::createMinerStateInstanceByName('init');
        }
@@ -216,7 +219,7 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable {
                $this->getStateInstance()->validateMinerStateIsInit();
 
                // Change it to 'booting'
-               MinerStateFactory::createMinerStateInstanceByName('booting', $this);
+               MinerStateFactory::createMinerStateInstanceByName('booting');
        }
 }