You are here

function search_api_saved_searches_entity_property_info_alter in Search API Saved Searches 7

Implements hook_entity_property_info_alter().

Corrects the types which the Entity API automatically infers from the schema. Otherwise, the "token" types would be "text", and "boolean" and "date" would be "integer". Also, changes saved search results to be a list, not just a CSV string.

Fixing this here automatically also fixes the Views integration provided by the Entity API, regarding these types.

File

./search_api_saved_searches.module, line 171
Offers the ability to save searches and be notified of new results.

Code

function search_api_saved_searches_entity_property_info_alter(array &$info) {
  $settings =& $info['search_api_saved_searches_settings']['properties'];
  $settings['index_id']['type'] = 'token';
  $settings['enabled']['type'] = 'boolean';
  $settings['module']['type'] = 'token';
  $searches =& $info['search_api_saved_search']['properties'];
  $searches['settings_id']['type'] = 'token';
  $searches['enabled']['type'] = 'boolean';
  $searches['created']['type'] = 'date';
  $searches['last_queued']['type'] = 'date';
  $searches['last_execute']['type'] = 'date';

  // We can't assign "duration" until Entity API Views integration supports
  // this.

  //$searches['notify_interval']['type'] = 'duration';
  $searches['results']['type'] = 'list<token>';
  $searches['results']['getter callback'] = 'search_api_saved_searches_get_results_property';
}