class ApachesolrAttachmentsEntityFieldQuery in Apache Solr Attachments 7
Same name and namespace in other branches
- 6.3 apachesolr_attachments.module \ApachesolrAttachmentsEntityFieldQuery
Hierarchy
- class \EntityFieldQuery
Expanded class hierarchy of ApachesolrAttachmentsEntityFieldQuery
File
- ./
apachesolr_attachments.module, line 779 - Provides a file attachment search implementation for use with the Apache Solr module
View source
class ApachesolrAttachmentsEntityFieldQuery extends EntityFieldQuery {
// Extra added fields to the query
private $addedFields = array();
/**
* Finishes the query.
*
* Adds tags, metaData, range and returns the requested list or count.
*
* @param SelectQuery $select_query
* A SelectQuery which has entity_type, entity_id, revision_id and bundle
* fields added.
* @param $id_key
* Which field's values to use as the returned array keys.
*
* @return
* See EntityFieldQuery::execute().
*/
function finishQuery($select_query, $id_key = 'entity_id') {
foreach ($this->tags as $tag) {
$select_query
->addTag($tag);
}
foreach ($this->metaData as $key => $object) {
$select_query
->addMetaData($key, $object);
}
$select_query
->addMetaData('entity_field_query', $this);
if ($this->range) {
$select_query
->range($this->range['start'], $this->range['length']);
}
if ($this->count) {
return $select_query
->countQuery()
->execute()
->fetchField();
}
$return = array();
foreach ($this->addedFields as $addedField) {
$fields = $select_query
->getFields();
if (!empty($addedField['field_name'])) {
$column = $addedField['field_name'] . '_' . $addedField['column'];
$column_alias = $addedField['field_name'] . '_' . $addedField['column_alias'];
}
else {
$column = $addedField['column'];
$column_alias = $addedField['column_alias'];
}
$select_query
->addField($fields['entity_id']['table'], $column, $column_alias);
}
foreach ($select_query
->execute() as $partial_entity) {
$bundle = isset($partial_entity->bundle) ? $partial_entity->bundle : NULL;
$entity = entity_create_stub_entity($partial_entity->entity_type, array(
$partial_entity->entity_id,
$partial_entity->revision_id,
$bundle,
));
// This is adding the file id using our metaData field.
$entity->extraFields = $partial_entity;
//$entity->file_fid = $partial_entity->{$this->metaData['field_key']};
$return[$partial_entity->entity_type][$partial_entity->{$id_key} . '_' . $partial_entity->{$column}] = $entity;
$this->ordered_results[] = $partial_entity;
}
return $return;
}
public function addExtraField($field_name, $column, $column_alias = NULL) {
$this->addedFields[] = array(
'field_name' => $field_name,
'column' => $column,
'column_alias' => $column_alias,
);
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ApachesolrAttachmentsEntityFieldQuery:: |
private | property | ||
ApachesolrAttachmentsEntityFieldQuery:: |
public | function | ||
ApachesolrAttachmentsEntityFieldQuery:: |
function |
Finishes the query. Overrides EntityFieldQuery:: |
||
EntityFieldQuery:: |
public | property | Flag indicating whether this is querying current or all revisions. | |
EntityFieldQuery:: |
public | property | TRUE if the query has already been altered, FALSE if it hasn't. | |
EntityFieldQuery:: |
public | property | TRUE if this is a count query, FALSE if it isn't. | |
EntityFieldQuery:: |
public | property | Query behavior for deleted data. | |
EntityFieldQuery:: |
public | property | Associative array of entity-generic metadata conditions. | |
EntityFieldQuery:: |
public | property | The method executing the query, if it is overriding the default. | |
EntityFieldQuery:: |
public | property | List of field conditions. | |
EntityFieldQuery:: |
public | property | List of field meta conditions (language and delta). | |
EntityFieldQuery:: |
public | property | A list of field arrays used. | |
EntityFieldQuery:: |
public | property | A list of metadata added to this query. | |
EntityFieldQuery:: |
public | property | List of order clauses. | |
EntityFieldQuery:: |
public | property | The ordered results. | |
EntityFieldQuery:: |
public | property | The query pager data. | |
EntityFieldQuery:: |
public | property | List of property conditions. | |
EntityFieldQuery:: |
public | property | The query range. | |
EntityFieldQuery:: |
public | property | A list of the tags added to this query. | |
EntityFieldQuery:: |
public | function | Adds a condition to an already built SelectQuery (internal function). | |
EntityFieldQuery:: |
protected | function | Adds the given condition to the proper condition array. | |
EntityFieldQuery:: |
public | function | Adds additional metadata to the query. | |
EntityFieldQuery:: |
public | function | Adds a tag to the query. | |
EntityFieldQuery:: |
public | function | Queries the current or every revision. | |
EntityFieldQuery:: |
public | function | Sets the query to be a count query only. | |
EntityFieldQuery:: |
public | function | Filters on the data being deleted. | |
EntityFieldQuery:: |
public | function | Adds a condition on entity-generic metadata. | |
EntityFieldQuery:: |
public | function | Orders the result set by entity-generic metadata. | |
EntityFieldQuery:: |
public | function | Executes the query. | |
EntityFieldQuery:: |
public | function | Adds a condition on field values. | |
EntityFieldQuery:: |
public | function | Adds a condition on the field delta column. | |
EntityFieldQuery:: |
public | function | Adds a condition on the field language column. | |
EntityFieldQuery:: |
public | function | Orders the result set by a given field column. | |
EntityFieldQuery:: |
function | Gets the total number of results and initializes a pager for the query. | ||
EntityFieldQuery:: |
public | function | Enables a pager for the query. | |
EntityFieldQuery:: |
public | function | Adds a condition on an entity-specific property. | |
EntityFieldQuery:: |
public | function | Orders the result set by an entity-specific property. | |
EntityFieldQuery:: |
protected | function | Queries entity tables in SQL for property conditions and sorts. | |
EntityFieldQuery:: |
public | function | Determines the query callback to use for this entity query. | |
EntityFieldQuery:: |
public | function | Restricts a query to a given range in the result set. | |
EntityFieldQuery:: |
constant | Indicates that both deleted and non-deleted fields should be returned. | ||
EntityFieldQuery:: |
public | function | Enables sortable tables for this query. |