}
/**
- * Creates an instance of a Tcp command resolver with a given default command
+ * Creates an instance of a TCP protocol resolver
*
* @return $resolverInstance The prepared command resolver instance
*/
}
/**
- * Returns an command instance for a given NodeHelper instance or null if it
- * was not found.
+ * Returns an instance of a LocateableNode class for a given NodeHelper
+ * instance or null if it was not found.
*
* @param $nodeInstance An instance of a NodeHelper class
* @return $unlInstance An instance of a LocateableNode class
* @todo 0% done
*/
- public function resolveUniversalResourceLocatorFromNodeHelper (NodeHelper $nodeInstance) {
- $this->partialStub('Please implement this method.');
+ public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) {
+ // Get result instance
+ $resultInstance = $nodeInstance->getResultInstance();
+
+ // Make sure the result instance is valid
+ assert($resultInstance instanceof SearchableResult);
+
+ // Rewind iterator
+ $resultInstance->rewind();
+
+ // Lookup node's id
+ while ($resultInstance->next()) {
+ // Get current entry
+ $current = $resultInstance->current();
+
+ // Do we have found an entry?
+ // $nodeInstance->getNodeId()
+ die(print_r($current, TRUE));
+ } // END - while
+ }
+
+ /**
+ * Returns the UNL as string from given configuration key.
+ *
+ * @param $configKey Configuration key for UNL address (valid: internal,external)
+ * @return $unl Universal node locator
+ */
+ public function resolveUniversalNodeLocatorFromConfigKey ($configKey) {
+ // Put all together
+ $unl = sprintf('%s://%s:%s',
+ $this->getProtocolName(),
+ $this->getConfigInstance()->getConfigEntry($configKey . '_address'),
+ $this->getConfigInstance()->getConfigEntry('node_listen_port')
+ );
+
+ /*
+ * And return it. Please note that e.g. a FaxProtocolResolver will
+ * return a different UNL and therefore all protocol resolvers must do
+ * it on their own way.
+ */
+ return $unl;
}
}