summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Seidl2011-07-12 20:32:45 (GMT)
committer Thomas Seidl2011-07-12 20:32:45 (GMT)
commitf93dbb8bb6d6acd47970c239824ae3670d014d65 (patch)
treee5b61a8ea559d02ee563d8c38c9e696cacf1c9fb
parent67978fbad6a6adaaed7bdf740e5d50dd824d62f8 (diff)
Issue #1214862 by drunken monkey: Added bundle-specific fields for related entities.
-rw-r--r--CHANGELOG.txt1
-rw-r--r--includes/index_entity.inc4
-rw-r--r--search_api.module13
3 files changed, 17 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 947dfbd..f0ea3b4 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,5 +1,6 @@
Search API 1.0, dev (xx/xx/xxxx):
---------------------------------
+- #1214862 by drunken monkey: Added bundle-specific fields for related entities.
- #1204964 by klausi: Fixed default index status is not overridden on saving.
- #1191442 by drunken monkey: Fixed facets block view showing only tid.
- #1161532 by drunken monkey: Fixed discerning between delete and revert in
diff --git a/includes/index_entity.inc b/includes/index_entity.inc
index 2b080a7..fd9ded5 100644
--- a/includes/index_entity.inc
+++ b/includes/index_entity.inc
@@ -693,7 +693,9 @@ class SearchApiIndex extends Entity {
* index.
*/
public function entityWrapper($item = NULL) {
- return entity_metadata_wrapper($this->entity_type, $item, array('property info alter' => array($this, 'propertyInfoAlter')));
+ $info['property info alter'] = array($this, 'propertyInfoAlter');
+ $info['property defaults']['property info alter'] = '_search_api_wrapper_add_all_properties';
+ return entity_metadata_wrapper($this->entity_type, $item, $info);
}
}
diff --git a/search_api.module b/search_api.module
index ab96b60..4dbbdcc 100644
--- a/search_api.module
+++ b/search_api.module
@@ -1757,3 +1757,16 @@ function search_api_index_delete($id) {
$index->delete();
return TRUE;
}
+
+/**
+ * Helper function to be used as a "property info alter" callback.
+ *
+ * If a wrapped entity is passed to this function, all its available properties
+ * and fields, regardless of bundle, are added to the wrapper.
+ */
+function _search_api_wrapper_add_all_properties(EntityMetadataWrapper $wrapper, array $property_info) {
+ if ($properties = entity_get_all_property_info($wrapper->type())) {
+ $property_info['properties'] = $properties;
+ }
+ return $property_info;
+}