protected function RestfulEntityBase::getQueryForAutocomplete in RESTful 7
Request the query object to get a list for autocomplete.
Return value
EntityFieldQuery Return a query object, before it is executed.
1 call to RestfulEntityBase::getQueryForAutocomplete()
- RestfulEntityBase::getQueryResultForAutocomplete in plugins/
restful/ RestfulEntityBase.php - Returns the result of a query for the auto complete.
File
- plugins/
restful/ RestfulEntityBase.php, line 218 - Contains RestfulEntityBase.
Class
- RestfulEntityBase
- An abstract implementation of RestfulEntityInterface.
Code
protected function getQueryForAutocomplete() {
$autocomplete_options = $this
->getPluginKey('autocomplete');
$entity_type = $this
->getEntityType();
$entity_info = $this
->getEntityInfo();
$request = $this
->getRequest();
$string = drupal_strtolower($request['autocomplete']['string']);
$operator = !empty($request['autocomplete']['operator']) ? $request['autocomplete']['operator'] : $autocomplete_options['operator'];
$query = $this
->EFQObject();
$query
->entityCondition('entity_type', $entity_type);
if ($bundles = $this
->getBundlesForAutocomplete()) {
$query
->entityCondition('bundle', $bundles, 'IN');
}
$query
->propertyCondition($entity_info['entity keys']['label'], $string, $operator);
// Add a generic entity access tag to the query.
$query
->addTag($entity_type . '_access');
$query
->addTag('restful');
$query
->addMetaData('restful_handler', $this);
$query
->addMetaData('account', $this
->getAccount());
// Sort by label.
$query
->propertyOrderBy($entity_info['entity keys']['label']);
// Add range.
$query
->range(0, $autocomplete_options['range']);
return $query;
}