/* {{{ proto array SolrInputDocument::toArray(void) Returns an array representation of the object. */ PHP_METHOD(SolrInputDocument, toArray) { solr_document_t *doc_entry = NULL; zval fields_array; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht; array_init(return_value); array_init(&fields_array); zend_hash_init(Z_ARRVAL(fields_array), zend_hash_num_elements(doc_entry->fields), NULL, ZVAL_PTR_DTOR, 0); add_assoc_double(return_value, "document_boost", doc_entry->document_boost); add_assoc_long(return_value, "field_count", doc_entry->field_count); add_assoc_zval(return_value, "fields", &fields_array); fields_ht = doc_entry->fields; SOLR_HASHTABLE_FOR_LOOP(fields_ht) { solr_field_list_t *field = NULL; zval current_field; zval *current_field_ptr = ¤t_field; field = zend_hash_get_current_data_ptr(fields_ht); /* create SolrDocumentField */ solr_create_document_field_object(field, ¤t_field_ptr TSRMLS_CC); /* create SolrDocumentField to the fields HT */ add_next_index_zval(&fields_array, current_field_ptr); } /* We are done */ return; }
/* {{{ proto array SolrInputDocument::getFieldNames(void) Returns an array of all the field names in the document. */ PHP_METHOD(SolrInputDocument, getFieldNames) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht = doc_entry->fields; register zend_bool duplicate = 0; array_init(return_value); SOLR_HASHTABLE_FOR_LOOP(fields_ht) { char *fieldname = NULL; uint fieldname_length = 0U; ulong num_index = 0L; solr_field_list_t **field = NULL; zend_bool duplicate_field_name = 1; // TODO check uselessness // zend_hash_get_current_key_ex(fields_ht, &fieldname, &fieldname_length, &num_index, duplicate, NULL); field = zend_hash_get_current_data_ptr(fields_ht); add_next_index_string(return_value, (char *) (*field)->field_name); } /* We are done */ return; }
static void call_resolved_handlers(skyray_promise_t *self, zend_array *on_fulfilled, zend_array *on_rejected) { skyray_promise_t *promise = skyray_promise_from_obj(Z_OBJ_P(&self->result)); zend_array *handlers; if (instanceof_function(Z_OBJCE_P(&self->result), skyray_ce_FulfilledPromise)) { handlers = on_fulfilled; } else { handlers = on_rejected; } zend_hash_internal_pointer_reset(handlers); while(zend_hash_has_more_elements(handlers) == SUCCESS) { promise_resolve_context_t *context = zend_hash_get_current_data_ptr(handlers); promise_resolve_context_call(context, &promise->result); zend_hash_move_forward(handlers); } zend_hash_destroy(&self->on_fulfilled); zend_hash_destroy(&self->on_rejcted); }