]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php
Continued with refacturing:
[hub.git] / application / hub / main / resolver / protocol / tcp / class_TcpProtocolResolver.php
index 8a3aae4bf4f5a01c33bba2dab2e088ff1124ca36..32f86bad3e4a230cc44a21d604801b0e2fbea414 100644 (file)
@@ -57,24 +57,32 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv
         * @todo        0% done
         */
        public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) {
-               // Get result instance
-               $resultInstance = $nodeInstance->getResultInstance();
+               // Get search instance (to lookup database result)
+               $searchInstance = $nodeInstance->getSearchInstance();
 
-               // Make sure the result instance is valid
-               assert($resultInstance instanceof SearchableResult);
+               // Make sure the in stance is valid
+               assert($searchInstance instanceof SearchCriteria);
 
-               // Rewind iterator
-               $resultInstance->rewind();
+               // Refetch and rewind iterator
+               $resultInstance = $nodeInstance->getWrapperInstance()->doSelectByCriteria($searchInstance);
 
-               // Lookup node's id
-               while ($resultInstance->next()) {
-                       // Get current entry
-                       $current = $resultInstance->current();
+               // Is the result valid?
+               if ((!$resultInstance->valid()) || (! $resultInstance->next())) {
+                       // Node not found in database, this could mean that your database file is damaged.
+                       return NULL;
+               } // END - if
 
-                       // Do we have found an entry?
-                       // $nodeInstance->getNodeId()
-                       die(print_r($current, TRUE));
-               } // END - while
+               // Get current entry
+               $current = $resultInstance->current();
+
+               // This should always be the case, if not your database file might be damaged.
+               assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]);
+
+               // Get UNL instance and handle over all data
+               $unlInstance = ObjectFactory::createObjectByConfiguredName('universal_node_locator_class', array($current));
+
+               // Return resolved instance
+               return $unlInstance;
        }
 
        /**