class SearchApiLiveResultsSearch in Search API live results 7
Class describing the settings for a certain search for which autocompletion is available.
Hierarchy
- class \Entity implements EntityInterface
- class \SearchApiLiveResultsSearch
Expanded class hierarchy of SearchApiLiveResultsSearch
1 string reference to 'SearchApiLiveResultsSearch'
- search_api_live_results_entity_info in ./
search_api_live_results.module - Implements hook_entity_info().
File
- ./
search_api_live_results.module, line 291
View source
class SearchApiLiveResultsSearch extends Entity {
// Entity properties, loaded from the database:
/**
* @var integer
*/
public $id;
/**
* @var string
*/
public $machine_name;
/**
* @var string
*/
public $name;
/**
* @var integer
*/
public $index_id;
/**
* @var string
*/
public $type;
/**
* @var boolean
*/
public $enabled;
/**
* An array of options for this search, containing any of the following:
* - results: Boolean indicating whether to also list the estimated number of
* results for each suggestion (if possible).
* - custom: An array of type-specific settings.
*
* @var array
*/
public $options = array();
// Inferred properties, for caching:
/**
* @var SearchApiIndex
*/
protected $index;
/**
* @var SearchApiServer
*/
protected $server;
/**
* Constructor.
*
* @param array $values
* The entity properties.
*/
public function __construct(array $values = array()) {
parent::__construct($values, 'search_api_live_results_search');
}
/**
* @return SearchApiIndex
* The index this search belongs to.
*/
public function index() {
if (!isset($this->index)) {
$this->index = search_api_index_load($this->index_id);
if (!$this->index) {
$this->index = FALSE;
}
}
return $this->index;
}
/**
* @return SearchApiServer
* The server this search would at the moment be executed on.
*/
public function server() {
if (!isset($this->server)) {
if (!$this
->index() || !$this
->index()->server) {
$this->server = FALSE;
}
else {
$this->server = $this
->index()
->server();
if (!$this->server) {
$this->server = FALSE;
}
}
}
return $this->server;
}
/**
* Helper method for altering a textfield form element to use live results.
*/
public function alterElement(array &$element) {
if (user_access('use_search_api_live_results')) {
$element['#type'] = 'live_results_search';
if (isset($this->options['caching']) && $this->options['caching']) {
$element['#autocomplete_path'] = drupal_get_path('module', 'search_api_live_results') . '/search_api_live_results.results.php';
$element['#autocomplete_query'] = array(
'search' => $this->machine_name,
);
}
else {
$element['#autocomplete_path'] = 'search_api_live_results/' . $this->machine_name;
}
}
}
/**
* Create the query that would be issued for this search for the complete keys.
*
* @param $complete
* A string containing the complete search keys.
* @param $incomplete
* A string containing the incomplete last search key.
*
* @return SearchApiQueryInterface
* The query that would normally be executed when only $complete was entered
* as the search keys for this search.
*/
public function getQuery($keys) {
$info = search_api_live_results_get_types($this->type);
if (empty($info['create query'])) {
return NULL;
}
$query = $info['create query']($this, $keys);
return $query;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Entity:: |
protected | property | 1 | |
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
protected | property | ||
Entity:: |
public | function |
Builds a structured array representing the entity's content. Overrides EntityInterface:: |
1 |
Entity:: |
public | function |
Returns the bundle of the entity. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Defines the entity label if the 'entity_class_label' callback is used. | 1 |
Entity:: |
protected | function | Override this in order to implement a custom default URI and specify 'entity_class_uri' as 'uri callback' hook_entity_info(). | |
Entity:: |
public | function |
Permanently deletes the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the info of the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the type of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Exports the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Gets the raw, translated value of a property or field. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks if the entity has a certain exportable status. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the entity identifier, i.e. the entities name or numeric id. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the internal, numeric identifier. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Checks whether the entity is the default revision. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the label of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Permanently saves the entity. Overrides EntityInterface:: |
|
Entity:: |
protected | function | Set up the object instance on construction or unserializiation. | |
Entity:: |
public | function |
Returns the uri of the entity just as entity_uri(). Overrides EntityInterface:: |
|
Entity:: |
public | function |
Generate an array for rendering the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function |
Returns the EntityMetadataWrapper of the entity. Overrides EntityInterface:: |
|
Entity:: |
public | function | Magic method to only serialize what's necessary. | |
Entity:: |
public | function | Magic method to invoke setUp() on unserialization. | |
SearchApiLiveResultsSearch:: |
public | property | ||
SearchApiLiveResultsSearch:: |
public | property | ||
SearchApiLiveResultsSearch:: |
protected | property | ||
SearchApiLiveResultsSearch:: |
public | property | ||
SearchApiLiveResultsSearch:: |
public | property | ||
SearchApiLiveResultsSearch:: |
public | property | ||
SearchApiLiveResultsSearch:: |
public | property | An array of options for this search, containing any of the following: | |
SearchApiLiveResultsSearch:: |
protected | property | ||
SearchApiLiveResultsSearch:: |
public | property | ||
SearchApiLiveResultsSearch:: |
public | function | Helper method for altering a textfield form element to use live results. | |
SearchApiLiveResultsSearch:: |
public | function | Create the query that would be issued for this search for the complete keys. | |
SearchApiLiveResultsSearch:: |
public | function | ||
SearchApiLiveResultsSearch:: |
public | function | ||
SearchApiLiveResultsSearch:: |
public | function |
Constructor. Overrides Entity:: |