summaryrefslogtreecommitdiff
path: root/modules/field/field.attach.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-06-14 15:41:03 +0000
committerDries Buytaert <dries@buytaert.net>2010-06-14 15:41:03 +0000
commit9cf21be9949ad70b4fb41eed0d4b8204afead2f8 (patch)
treec01d1e3cc750c26a541f81a293ea9bcbd64d73a8 /modules/field/field.attach.inc
parentf6d56f96c306a9e9ec3202c087321edc39d65b03 (diff)
downloadbrdo-9cf21be9949ad70b4fb41eed0d4b8204afead2f8.tar.gz
brdo-9cf21be9949ad70b4fb41eed0d4b8204afead2f8.tar.bz2
- Patch #780154 by chx, noahb, dhthwy, pwolanin, aspilicious, jhodgdon, dereine, bjaspan: listing API for field API.
Diffstat (limited to 'modules/field/field.attach.inc')
-rw-r--r--modules/field/field.attach.inc135
1 files changed, 0 insertions, 135 deletions
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index b1f6a57e0..d461eca46 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -31,15 +31,6 @@ class FieldValidationException extends FieldException {
}
/**
- * Exception thrown by field_attach_query() on unsupported query syntax.
- *
- * Some storage modules might not support the full range of the syntax for
- * conditions, and will raise a FieldQueryException when an usupported
- * condition was specified.
- */
-class FieldQueryException extends FieldException {}
-
-/**
* @defgroup field_storage Field Storage API
* @{
* Implement a storage engine for Field API data.
@@ -1046,132 +1037,6 @@ function field_attach_delete_revision($entity_type, $entity) {
}
/**
- * Retrieve entities matching a given set of conditions.
- *
- * Note that the query 'conditions' only apply to the stored values.
- * In a regular field_attach_load() call, field values additionally go through
- * hook_field_load() and hook_field_attach_load() invocations, which can add
- * to or affect the raw stored values. The results of field_attach_query()
- * might therefore differ from what could be expected by looking at a regular,
- * fully loaded entity.
- *
- * @param $field_id
- * The id of the field to query.
- * @param $conditions
- * An array of query conditions. Each condition is a numerically indexed
- * array, in the form: array(column, value, operator).
- * Not all storage engines are required to support queries on all column, or
- * with all operators below. A FieldQueryException will be raised if an
- * unsupported condition is specified.
- * Supported columns:
- * - any of the columns defined in hook_field_schema() for $field_name's
- * field type: condition on field value,
- * - 'type': condition on entity type (e.g. 'node', 'user'...),
- * - 'bundle': condition on entity bundle (e.g. node type),
- * - 'entity_id': condition on entity id (e.g node nid, user uid...),
- * - 'deleted': condition on whether the field's data is
- * marked deleted for the entity (defaults to FALSE if not specified)
- * The field_attach_query_revisions() function additionally supports:
- * - 'revision_id': condition on entity revision id (e.g node vid).
- * Supported operators:
- * - '=', '!=', '>', '>=', '<', '<=', 'STARTS_WITH', 'ENDS_WITH',
- * 'CONTAINS': these operators expect the value as a literal of the same
- * type as the column,
- * - 'IN', 'NOT IN': this operator expects the value as an array of
- * literals of the same type as the column.
- * - 'BETWEEN': this operator expects the value as an array of two literals
- * of the same type as the column.
- * The operator can be ommitted, and will default to 'IN' if the value is
- * an array, or to '=' otherwise.
- * Example values for $conditions:
- * @code
- * array(
- * array('type', 'node'),
- * );
- * array(
- * array('bundle', array('article', 'page')),
- * array('value', 12, '>'),
- * );
- * @endcode
- * @param $options
- * An associative array of additional options:
- * - limit: The number of results that is requested. This is only a hint to
- * the storage engine(s); callers should be prepared to handle fewer or
- * more results. Specify FIELD_QUERY_NO_LIMIT to retrieve all available
- * entities. This option has a default value of 0 so callers must make an
- * explicit choice to potentially retrieve an enormous result set.
- * - cursor: A reference to an opaque cursor that allows a caller to iterate
- * through multiple result sets. On the first call, pass 0; the correct
- * value to pass on the next call will be written into the value on return.
- * When there is no more query data available, the value will be filled in
- * with FIELD_QUERY_COMPLETE. If cursor is passed as NULL, the first result
- * set is returned and no next cursor is returned.
- * - count: If TRUE, return a single count of all matching entities; limit and
- * cursor are ignored.
- * - age: Internal use only. Use field_attach_query_revisions() instead of
- * passing FIELD_LOAD_REVISION.
- * - FIELD_LOAD_CURRENT (default): query the most recent revisions for all
- * entities. The results will be keyed by entity type and entity id.
- * - FIELD_LOAD_REVISION: query all revisions. The results will be keyed by
- * entity type and entity revision id.
- * @return
- * An array keyed by entity type (e.g. 'node', 'user'...), then by entity id
- * or revision id (depending of the value of the $age parameter). The values
- * are pseudo-entities with the bundle, id, and revision id fields filled in.
- * Throws a FieldQueryException if the field's storage doesn't support the
- * specified conditions.
- */
-function field_attach_query($field_id, $conditions, $options = array()) {
- // Merge in default options.
- $default_options = array(
- 'limit' => 0,
- 'cursor' => 0,
- 'count' => FALSE,
- 'age' => FIELD_LOAD_CURRENT,
- );
- $options += $default_options;
-
- // Give a chance to 3rd party modules that bypass the storage engine to
- // handle the query.
- $skip_field = FALSE;
- foreach (module_implements('field_storage_pre_query') as $module) {
- $function = $module . '_field_storage_pre_query';
- $results = $function($field_id, $conditions, $options, $skip_field);
- // Stop as soon as a module claims it handled the query.
- if ($skip_field) {
- break;
- }
- }
- // If the request hasn't been handled, let the storage engine handle it.
- if (!$skip_field) {
- $field = field_info_field_by_id($field_id);
- $function = $field['storage']['module'] . '_field_storage_query';
- $results = $function($field_id, $conditions, $options);
- }
-
- return $results;
-}
-
-/**
- * Retrieve entity revisions matching a given set of conditions.
- *
- * See field_attach_query() for more informations.
- *
- * @param $field_id
- * The id of the field to query.
- * @param $conditions
- * See field_attach_query().
- * @param $options
- * An associative array of additional options. See field_attach_query().
- * @return
- * See field_attach_query().
- */
-function field_attach_query_revisions($field_id, $conditions, $options = array()) {
- $options['age'] = FIELD_LOAD_REVISION;
- return field_attach_query($field_id, $conditions, $options);
-}
-
-/**
* Prepare field data prior to display.
*
* This function must be called before field_attach_view(). It lets field