You are here

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

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

Namesort descending Modifiers Type Description Overrides
entity_views_example_query::add_selector_orderby abstract public function Add a sort to the query.
entity_views_example_query::get_result_entities abstract public function Returns the according entity objects for the given query results. Overrides views_plugin_query::get_result_entities
entity_views_example_query::get_result_wrappers abstract public function Returns the according metadata wrappers for the given query results.
views_object::$definition public property Handler's definition.
views_object::$options public property Except for displays, options for the object will be held here. 1
views_object::altered_option_definition function Collect this handler's option definition and alter them, ready for use.
views_object::construct public function Views handlers use a special construct function. 4
views_object::destroy public function Destructor. 2
views_object::export_option public function 1
views_object::export_options public function
views_object::export_option_always public function Always exports the option, regardless of the default value.
views_object::options Deprecated public function Set default options on this object. 1
views_object::option_definition public function Information about options for all kinds of purposes will be held here. 13
views_object::set_default_options public function Set default options.
views_object::set_definition public function Let the handler know what its full definition is.
views_object::unpack_options public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
views_object::unpack_translatable public function Unpack a single option definition.
views_object::unpack_translatables public function Unpacks each handler to store translatable texts.
views_object::_set_option_defaults public function
views_plugin::$display public property The current used views display.
views_plugin::$plugin_name public property The plugin name of this plugin, for example table or full.
views_plugin::$plugin_type public property The plugin type of this plugin, for example style or query.
views_plugin::$view public property The top object of a view. Overrides views_object::$view 1
views_plugin::additional_theme_functions public function Provide a list of additional theme functions for the theme info page.
views_plugin::plugin_title public function Return the human readable name of the display.
views_plugin::theme_functions public function Provide a full list of possible theme templates used by this style.
views_plugin::validate public function Validate that the plugin is correct and can be saved. 3
views_plugin_query::$pager public property A pager plugin that should be provided by the display. 1
views_plugin_query::add_signature public function Add a signature to the query, if such a thing is feasible. 1
views_plugin_query::alter public function Let modules modify the query just prior to finalizing it. 1
views_plugin_query::build public function Builds the necessary info to execute the query. 1
views_plugin_query::execute public function Executes the query and fills the associated view object with according values. 1
views_plugin_query::get_aggregation_info public function Get aggregation info for group by queries. 1
views_plugin_query::init public function Constructor; Create the basic query object and fill with default values. 1
views_plugin_query::options_form public function Add settings for the ui. Overrides views_plugin::options_form 1
views_plugin_query::options_submit public function Handle any special handling on the validate form. Overrides views_plugin::options_submit 1
views_plugin_query::options_validate public function Validate the options form. Overrides views_plugin::options_validate
views_plugin_query::query public function Generate a query and a countquery from all of the information supplied to the object. Overrides views_plugin::query 1
views_plugin_query::render_pager public function Render the pager, if necessary.
views_plugin_query::set_group_operator public function Control how all WHERE and HAVING groups are put together.
views_plugin_query::set_limit public function Set a LIMIT on the query, specifying a maximum number of results.
views_plugin_query::set_offset public function Set an OFFSET on the query, specifying a number of results to skip
views_plugin_query::set_where_group public function Create a new grouping for the WHERE or HAVING clause.
views_plugin_query::summary_title public function Returns the summary of the settings in the display. Overrides views_plugin::summary_title