From 99d8bcb8c9474a6c8b8178bceee48545aeda7467 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 12 May 2015 00:13:23 +0200 Subject: [PATCH] Instance 'miner' is now added to registry in BaseHubMiner. Signed-off-by: Roland Haeder --- .../factories/states/miner/class_MinerStateFactory.php | 8 +++++--- .../main/filter/miner/class_MinerInitializationFilter.php | 3 --- application/hub/main/miner/class_BaseHubMiner.php | 5 ++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/application/hub/main/factories/states/miner/class_MinerStateFactory.php b/application/hub/main/factories/states/miner/class_MinerStateFactory.php index b947915c5..2b2a7e02f 100644 --- a/application/hub/main/factories/states/miner/class_MinerStateFactory.php +++ b/application/hub/main/factories/states/miner/class_MinerStateFactory.php @@ -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() . '.'); diff --git a/application/hub/main/filter/miner/class_MinerInitializationFilter.php b/application/hub/main/filter/miner/class_MinerInitializationFilter.php index 5785e5b95..bf922d51f 100644 --- a/application/hub/main/filter/miner/class_MinerInitializationFilter.php +++ b/application/hub/main/filter/miner/class_MinerInitializationFilter.php @@ -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); } } diff --git a/application/hub/main/miner/class_BaseHubMiner.php b/application/hub/main/miner/class_BaseHubMiner.php index eee201c95..8bbc29fa6 100644 --- a/application/hub/main/miner/class_BaseHubMiner.php +++ b/application/hub/main/miner/class_BaseHubMiner.php @@ -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'); } } -- 2.39.5