function sarnia_entity_property_info in Sarnia 7
Implements hook_entity_property_info().
This hook is provided by the Entity API module.
See also
File
- ./
sarnia.module, line 471
Code
function sarnia_entity_property_info() {
module_load_include('inc', 'sarnia', 'sarnia.entities');
$info = array();
$entity_types = _sarnia_entity_types();
foreach ($entity_types as $machine_name => $entity_info) {
$info[$machine_name]['properties'] = array();
// Add only fulltext fields as 'text' properties for Search API. If we
// wanted all fields, we would use $server->getRemoteFields(), but that
// could significantly increase the size of stored Search API index settings
// and other caches; indexes can easily have over a hundred fields.
// @see http://drupal.org/node/1308638
$server = search_api_server_load($entity_info['search_api_server']);
if ($server) {
foreach ($server
->getFulltextFields() as $key => $field) {
$info[$machine_name]['properties'][$key] = array(
'label' => $key,
'type' => 'text',
);
}
// Add date fields.
foreach ($server
->getRemoteFields() as $key => $field) {
if ($field
->getType() == 'tdate') {
$info[$machine_name]['properties'][$key] = array(
'label' => $key,
'type' => 'date',
);
}
}
// Organize properties alphabetically.
ksort($info[$machine_name]['properties']);
// Add the 'id' field first.
unset($info[$machine_name]['properties']['id']);
$info[$machine_name]['properties'] = array(
'id' => array(
'label' => t('Id'),
'type' => 'token',
'description' => t('An id from Solr.'),
'required' => TRUE,
),
) + $info[$machine_name]['properties'];
}
}
return $info;
}