* @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;
}
/**