diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 947dfbd7467f9ef3bcfa632732606d92a57d7609..f0ea3b48ecee44c71b8c44f60bc60720a987fff6 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 2b080a792c8ef08cbf06ef0a44a1ea524ec90a4e..fd9ded5672117b4e7c4771e76ee5a033da5a5fe6 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 ab96b600e1691182639b9faf529c859d22ce1b53..4dbbdccbbfe8e684ce492eb8d395b54f88849513 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; +}