- Removed 2nd parameter $crawlerInstance as this can be get from object registry
- Other improvements
Signed-off-by: Roland Haeder <roland@mxchange.org>
// CFG: MINER-BUFFER-STACKER-CLASS
$cfg->setConfigEntry('miner_buffer_stacker_class', 'FiFoStacker');
-// CFG: HUBCONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
+// CFG: HUB-CONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
$cfg->setConfigEntry('hub_console_cmd_miner_resolver_class', 'HubConsoleCommandResolver');
// CFG: MINER-PHP-REQUIREMENTS-FILTER
// CFG: CRUNCHER-BUFFER-STACKER-CLASS
$cfg->setConfigEntry('cruncher_buffer_stacker_class', 'FiFoStacker');
-// CFG: HUBCONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
+// CFG: HUB-CONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
$cfg->setConfigEntry('hubconsole_cmd_cruncher_resolver_class', 'HubConsoleCommandResolver');
// CFG: CRUNCHER-PHP-REQUIREMENTS-FILTER
// Chat Configuration
///////////////////////////////////////////////////////////////////////////////
-// CFG: HUBCONSOLE-CMD-CHAT-RESOLVER-CLASS
+// CFG: HUB-CONSOLE-CMD-CHAT-RESOLVER-CLASS
$cfg->setConfigEntry('hubconsole_cmd_chat_resolver_class', 'HubConsoleCommandResolver');
// CFG: CHAT-PHP-REQUIREMENTS-FILTER
// CFG: INDEX-EXTENSION
$cfg->setConfigEntry('index_extension', '.idx');
-// CFG: HUBCONSOLE-CMD-CHAT-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_crawler_resolver_class', 'HubConsoleCommandResolver');
+// CFG: HUB-CONSOLE-CMD-CHAT-RESOLVER-CLASS
+$cfg->setConfigEntry('hub_console_cmd_crawler_resolver_class', 'HubConsoleCommandResolver');
// CFG: CRAWLER-PHP-REQUIREMENTS-FILTER
$cfg->setConfigEntry('crawler_php_requirements_filter', 'CrawlerPhpRequirementsFilter');
// Apt-Proxy Configuration
///////////////////////////////////////////////////////////////////////////////
-// CFG: HUBCONSOLE-CMD-APT-PROXY-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_apt_proxy_resolver_class', 'HubConsoleCommandResolver');
+// CFG: HUB-CONSOLE-CMD-APT-PROXY-RESOLVER-CLASS
+$cfg->setConfigEntry('hub_console_cmd_apt_proxy_resolver_class', 'HubConsoleCommandResolver');
// CFG: APT-PROXY-PHP-REQUIREMENTS-FILTER
$cfg->setConfigEntry('apt_proxy_php_requirements_filter', 'AptProxyPhpRequirementsFilter');
*/
private $communicatorInstance = NULL;
- /**
- * An instance of a crawler
- */
- private $crawlerInstance = NULL;
-
/**
* An instance of a cruncher
*/
$this->communicatorInstance = $communicatorInstance;
}
- /**
- * Getter for crawler instance
- *
- * @return $crawlerInstance An instance of a Crawler class
- */
- public final function getCrawlerInstance () {
- return $this->crawlerInstance;
- }
-
- /**
- * Setter for crawler instance
- *
- * @param $crawlerInstance An instance of a Crawler class
- * @return void
- */
- protected final function setCrawlerInstance (Crawler $crawlerInstance) {
- $this->crawlerInstance = $crawlerInstance;
- }
-
/**
* Getter for cruncher instance
*
// Call parent constructor
parent::__construct($className);
+ // Set this crawler instance in registry
+ Registry::getRegistry()->addInstance('crawler', $this);
+
// Init state which sets the state to 'init'
$this->initState();
}
*/
private function initState() {
// Get the state factory and create the initial state.
- CrawlerStateFactory::createCrawlerStateInstanceByName('init', $this);
+ CrawlerStateFactory::createCrawlerStateInstanceByName('init');
}
/**
* given crawler instance.
*
* @param $stateName Name of the state
- * @param $crawlerInstance A Crawler class instance
* @return $stateInstance A Stateable class instance
*/
- public static final function createCrawlerStateInstanceByName ($stateName, Crawler $crawlerInstance) {
+ public static final function createCrawlerStateInstanceByName ($stateName) {
// Then construct the class' configuraton entry
$className = 'crawler_' . $stateName . '_state_class';
// Get a class from that configuration entry
- $stateInstance = self::createObjectByConfiguredName($className, array($crawlerInstance));
+ $stateInstance = self::createObjectByConfiguredName($className);
+
+ // Get crawler instance
+ $crawlerInstance = Registry::getRegistry()->getInstance('crawler');
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Crawler state has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
// Add crawler-specific filters
$crawlerInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
-
- // Set the crawler instance in registry
- Registry::getRegistry()->addInstance('crawler', $crawlerInstance);
}
}
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData()=' . count($csvData) . ' - CALLED!');
- // The array has 3 elements, later enhancements may accept more
+ // The array must have a fixed amount of elements, later enhancements may accept more
assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
/*
return;
} // END - if
- // ... with 3 elements, later enhancements may accept more
+ // ... with a fixed amount of elements, later enhancements may accept more
assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
/*
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData[' . gettype($csvData) . ']=' . print_r($csvData, TRUE));
- // It must have 3 elements (see method parseCsvFile() for details)
+ // It must have a fixed amount of elements (see method parseCsvFile() for details)
assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
// Save it in crawler queue (which will enrich it with way more informations
* @param $crawlerInstance An instance of a Crawler class
* @return $stateInstance An instance of a Stateable class
*/
- public static final function createCrawlerActiveState (Crawler $crawlerInstance) {
+ public static final function createCrawlerActiveState () {
// Get new instance
$stateInstance = new CrawlerActiveState();
- // Set the crawler instance
- $stateInstance->setCrawlerInstance($crawlerInstance);
-
// Return the prepared instance
return $stateInstance;
}
$this->partialStub('Unfinished method.');
// Change state to 'active'
- CrawlerStateFactory::createCrawlerStateInstanceByName('active', $this->getCrawlerInstance());
+ CrawlerStateFactory::createCrawlerStateInstanceByName('active');
}
/**
* Creates an instance of this class
*
- * @param $crawlerInstance An instance of a Crawler class
- * @return $stateInstance An instance of a Stateable class
+ * @return $stateInstance An instance of a Stateable class
*/
- public static final function createCrawlerBootingState (Crawler $crawlerInstance) {
+ public static final function createCrawlerBootingState () {
// Get new instance
$stateInstance = new CrawlerBootingState();
- // Set the crawler instance
- $stateInstance->setCrawlerInstance($crawlerInstance);
-
// Return the prepared instance
return $stateInstance;
}
/**
* Creates an instance of this class
*
- * @param $crawlerInstance An instance of a Crawler class
- * @return $stateInstance An instance of a Stateable class
+ * @return $stateInstance An instance of a Stateable class
*/
- public static final function createCrawlerInitState (Crawler $crawlerInstance) {
+ public static final function createCrawlerInitState () {
// Get new instance
$stateInstance = new CrawlerInitState();
- // Set the crawler instance
- $stateInstance->setCrawlerInstance($crawlerInstance);
-
// Return the prepared instance
return $stateInstance;
}
$this->partialStub('Unfinished method.');
// Change state to 'booting'
- CrawlerStateFactory::createCrawlerStateInstanceByName('booting', $this->getCrawlerInstance());
+ CrawlerStateFactory::createCrawlerStateInstanceByName('booting');
}
}