5 * Contains an example for a Views query plugin that could use the data selection tables.
9 * Describes the additional methods looked for on a query plugin if data selection based tables or fields are used.
11 * Only get_result_entities() needs to be present, so results can be retrieved.
12 * The other methods are optional.
14 * If the table does not contain entities, however, the get_result_wrappers()
15 * method is necessary, too. If this is the case and there are no relations to
16 * entity tables, the get_result_entities() method is not needed.
18 * @see entity_views_table_definition()
20 abstract class entity_views_example_query
extends views_plugin_query
{
23 * Add a sort to the query.
25 * This is used to add a sort based on an Entity API data selector instead
28 * This method has to be present if click-sorting on fields should be allowed
29 * for some fields using the default Entity API field handlers.
32 * The field to sort on, as an Entity API data selector.
34 * The order to sort items in - either 'ASC' or 'DESC'. Defaults to 'ASC'.
36 public abstract function add_selector_orderby($selector, $order = 'ASC');
39 * Returns the according entity objects for the given query results.
41 * This is compatible to the get_result_entities() method used by Views.
43 * The method is responsible for resolving the relationship and returning the
44 * entity objects for that relationship. The helper methods
45 * EntityFieldHandlerHelper::construct_property_selector() and
46 * EntityFieldHandlerHelper::extract_property_multiple() can be used to do
50 * The results of the query, as returned by this query plugin.
51 * @param $relationship
52 * (optional) A relationship for which the entities should be returned.
54 * (optional) The field for which the entity should be returned. This is
55 * only needed in case a field is derived via a referenced entity without
56 * using a relationship. For example, if the node's field "author:name" is
57 * used, the user entity would be returned instead of the node entity.
60 * A numerically indexed array containing two items: the entity type of
61 * entities returned by this method; and the array of entities, keyed by the
62 * same indexes as the results.
64 * @see EntityFieldHandlerHelper::extract_property_multiple()
66 public abstract function get_result_entities($results, $relationship = NULL, $field = NULL);
69 * Returns the according metadata wrappers for the given query results.
71 * This can be used if no entities for the results can be given, but entity
72 * metadata wrappers can be constructed for them.
75 * The results of the query, as returned by this query plugin.
76 * @param $relationship
77 * (optional) A relationship for which the wrappers should be returned.
79 * (optional) The field of which a wrapper should be returned.
82 * A numerically indexed array containing two items: the data type of
83 * the wrappers returned by this method; and the array of retrieved
84 * EntityMetadataWrapper objects, keyed by the same indexes as the results.
86 public abstract function get_result_wrappers($results, $relationship = NULL, $field = NULL);