* 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() . '.');
// @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);
}
}
* @return void
*/
private function initMiner () {
+ // Add own instance to registry
+ Registry::getRegistry()->addInstance('miner', $this);
+
// Init the state
MinerStateFactory::createMinerStateInstanceByName('init');
}
$this->getStateInstance()->validateMinerStateIsInit();
// Change it to 'booting'
- MinerStateFactory::createMinerStateInstanceByName('booting', $this);
+ MinerStateFactory::createMinerStateInstanceByName('booting');
}
}