abstract class entity_views_example_query in Entity API 7
Describes the additional methods looked for on a query plugin if data selection based tables or fields are used.
Only get_result_entities() needs to be present, so results can be retrieved. The other methods are optional.
If the table does not contain entities, however, the get_result_wrappers() method is necessary, too. If this is the case and there are no relations to entity tables, the get_result_entities() method is not needed.
Hierarchy
- class \views_object
- class \views_plugin
- class \views_plugin_query
- class \entity_views_example_query
- class \views_plugin_query
- class \views_plugin
Expanded class hierarchy of entity_views_example_query
See also
entity_views_table_definition()
File
- views/
entity_views_example_query.php, line 20 - Contains an example for a Views query plugin that could use the data selection tables.
View source
abstract class entity_views_example_query extends views_plugin_query {
/**
* Add a sort to the query.
*
* This is used to add a sort based on an Entity API data selector instead
* of a field alias.
*
* This method has to be present if click-sorting on fields should be allowed
* for some fields using the default Entity API field handlers.
*
* @param $selector
* The field to sort on, as an Entity API data selector.
* @param $order
* The order to sort items in - either 'ASC' or 'DESC'. Defaults to 'ASC'.
*/
public abstract function add_selector_orderby($selector, $order = 'ASC');
/**
* Returns the according entity objects for the given query results.
*
* This is compatible to the get_result_entities() method used by Views.
*
* The method is responsible for resolving the relationship and returning the
* entity objects for that relationship. The helper methods
* EntityFieldHandlerHelper::construct_property_selector() and
* EntityFieldHandlerHelper::extract_property_multiple() can be used to do
* this.
*
* @param $results
* The results of the query, as returned by this query plugin.
* @param $relationship
* (optional) A relationship for which the entities should be returned.
* @param $field
* (optional) The field for which the entity should be returned. This is
* only needed in case a field is derived via a referenced entity without
* using a relationship. For example, if the node's field "author:name" is
* used, the user entity would be returned instead of the node entity.
*
* @return array
* A numerically indexed array containing two items: the entity type of
* entities returned by this method; and the array of entities, keyed by the
* same indexes as the results.
*
* @see EntityFieldHandlerHelper::extract_property_multiple()
*/
public abstract function get_result_entities($results, $relationship = NULL, $field = NULL);
/**
* Returns the according metadata wrappers for the given query results.
*
* This can be used if no entities for the results can be given, but entity
* metadata wrappers can be constructed for them.
*
* @param $results
* The results of the query, as returned by this query plugin.
* @param $relationship
* (optional) A relationship for which the wrappers should be returned.
* @param $field
* (optional) The field of which a wrapper should be returned.
*
* @return array
* A numerically indexed array containing two items: the data type of
* the wrappers returned by this method; and the array of retrieved
* EntityMetadataWrapper objects, keyed by the same indexes as the results.
*/
public abstract function get_result_wrappers($results, $relationship = NULL, $field = NULL);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
entity_views_example_query:: |
abstract public | function | Add a sort to the query. | |
entity_views_example_query:: |
abstract public | function |
Returns the according entity objects for the given query results. Overrides views_plugin_query:: |
|
entity_views_example_query:: |
abstract public | function | Returns the according metadata wrappers for the given query results. | |
views_object:: |
public | property | Handler's definition. | |
views_object:: |
public | property | Except for displays, options for the object will be held here. | 1 |
views_object:: |
function | Collect this handler's option definition and alter them, ready for use. | ||
views_object:: |
public | function | Views handlers use a special construct function. | 4 |
views_object:: |
public | function | Destructor. | 2 |
views_object:: |
public | function | 1 | |
views_object:: |
public | function | ||
views_object:: |
public | function | Always exports the option, regardless of the default value. | |
views_object:: |
public | function | Set default options on this object. | 1 |
views_object:: |
public | function | Information about options for all kinds of purposes will be held here. | 13 |
views_object:: |
public | function | Set default options. | |
views_object:: |
public | function | Let the handler know what its full definition is. | |
views_object:: |
public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
views_object:: |
public | function | Unpack a single option definition. | |
views_object:: |
public | function | Unpacks each handler to store translatable texts. | |
views_object:: |
public | function | ||
views_plugin:: |
public | property | The current used views display. | |
views_plugin:: |
public | property | The plugin name of this plugin, for example table or full. | |
views_plugin:: |
public | property | The plugin type of this plugin, for example style or query. | |
views_plugin:: |
public | property |
The top object of a view. Overrides views_object:: |
1 |
views_plugin:: |
public | function | Provide a list of additional theme functions for the theme info page. | |
views_plugin:: |
public | function | Return the human readable name of the display. | |
views_plugin:: |
public | function | Provide a full list of possible theme templates used by this style. | |
views_plugin:: |
public | function | Validate that the plugin is correct and can be saved. | 3 |
views_plugin_query:: |
public | property | A pager plugin that should be provided by the display. | 1 |
views_plugin_query:: |
public | function | Add a signature to the query, if such a thing is feasible. | 1 |
views_plugin_query:: |
public | function | Let modules modify the query just prior to finalizing it. | 1 |
views_plugin_query:: |
public | function | Builds the necessary info to execute the query. | 1 |
views_plugin_query:: |
public | function | Executes the query and fills the associated view object with according values. | 1 |
views_plugin_query:: |
public | function | Get aggregation info for group by queries. | 1 |
views_plugin_query:: |
public | function | Constructor; Create the basic query object and fill with default values. | 1 |
views_plugin_query:: |
public | function |
Add settings for the ui. Overrides views_plugin:: |
1 |
views_plugin_query:: |
public | function |
Handle any special handling on the validate form. Overrides views_plugin:: |
1 |
views_plugin_query:: |
public | function |
Validate the options form. Overrides views_plugin:: |
|
views_plugin_query:: |
public | function |
Generate a query and a countquery from all of the information supplied
to the object. Overrides views_plugin:: |
1 |
views_plugin_query:: |
public | function | Render the pager, if necessary. | |
views_plugin_query:: |
public | function | Control how all WHERE and HAVING groups are put together. | |
views_plugin_query:: |
public | function | Set a LIMIT on the query, specifying a maximum number of results. | |
views_plugin_query:: |
public | function | Set an OFFSET on the query, specifying a number of results to skip | |
views_plugin_query:: |
public | function | Create a new grouping for the WHERE or HAVING clause. | |
views_plugin_query:: |
public | function |
Returns the summary of the settings in the display. Overrides views_plugin:: |