function dynamic_entity_reference_build_entity_query in Dynamic Entity Reference 7
Builds an EntityQuery to get referenceable entities.
Parameters
string $target_type: The target entity type.
string|null $match: (Optional) Text to match the label against. Defaults to NULL.
string $match_operator: (Optional) The operation the matching should be done with. Defaults to "CONTAINS".
Return value
SelectQueryInterface The EntityQuery object with the basic conditions and sorting applied to it.
1 call to dynamic_entity_reference_build_entity_query()
- dynamic_entity_reference_get_referenceable_entities in ./
dynamic_entity_reference.pages.inc - Gets referenceable entities.
File
- ./
dynamic_entity_reference.pages.inc, line 52 - Contains page callbacks for the module.
Code
function dynamic_entity_reference_build_entity_query($target_type, $match = NULL, $match_operator = 'CONTAINS') {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $target_type);
$entity_info = entity_get_info($target_type);
if (isset($match) && isset($entity_info['entity keys']['label']) && ($label_key = $entity_info['entity keys']['label'])) {
$query
->propertyCondition($label_key, $match, $match_operator);
$query
->propertyOrderBy($label_key, 'ASC');
}
// Add entity-access tag.
$query
->addTag($target_type . '_access');
return $query;
}