abstract class QueryPluginBase

@todo.

Hierarchy

Expanded class hierarchy of QueryPluginBase

1 file declares its use of QueryPluginBase
QueryTest.php in drupal/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php
Definition of Drupal\views_test_data\Plugin\views\query\QueryTest.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/query/QueryPluginBase.php, line 17
Definition of Drupal\views\Plugin\views\query\QueryPluginBase.

Namespace

Drupal\views\Plugin\views\query
View source
abstract class QueryPluginBase extends PluginBase implements QueryInterface {

  /**
   * A pager plugin that should be provided by the display.
   *
   * @var views_plugin_pager
   */
  var $pager = NULL;

  /**
   * Overrides Drupal\views\Plugin\views\PluginBase::init().
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array $options = array()) {
    $this->view = $view;
    $this->displayHandler = $display;
    $this
      ->setOptionDefaults($this->options, $this
      ->defineOptions());
    $this
      ->unpackOptions($this->options, $options);
  }

  /**
   * Generate a query and a countquery from all of the information supplied
   * to the object.
   *
   * @param $get_count
   *   Provide a countquery if this is true, otherwise provide a normal query.
   */
  public function query($get_count = FALSE) {
  }

  /**
   * Let modules modify the query just prior to finalizing it.
   *
   * @param view $view
   *   The view which is executed.
   */
  function alter(ViewExecutable $view) {
  }

  /**
   * Builds the necessary info to execute the query.
   *
   * @param view $view
   *   The view which is executed.
   */
  function build(ViewExecutable $view) {
  }

  /**
   * Executes the query and fills the associated view object with according
   * values.
   *
   * Values to set: $view->result, $view->total_rows, $view->execute_time,
   * $view->pager['current_page'].
   *
   * $view->result should contain an array of objects. The array must use a
   * numeric index starting at 0.
   *
   * @param view $view
   *   The view which is executed.
   */
  function execute(ViewExecutable $view) {
  }

  /**
   * Add a signature to the query, if such a thing is feasible.
   *
   * This signature is something that can be used when perusing query logs to
   * discern where particular queries might be coming from.
   *
   * @param view $view
   *   The view which is executed.
   */
  function add_signature(ViewExecutable $view) {
  }

  /**
   * Get aggregation info for group by queries.
   *
   * If NULL, aggregation is not allowed.
   */
  function get_aggregation_info() {
  }
  public function validateOptionsForm(&$form, &$form_state) {
  }
  public function submitOptionsForm(&$form, &$form_state) {
  }
  public function summaryTitle() {
    return t('Settings');
  }

  /**
   * Set a LIMIT on the query, specifying a maximum number of results.
   */
  function set_limit($limit) {
    $this->limit = $limit;
  }

  /**
   * Set an OFFSET on the query, specifying a number of results to skip
   */
  function set_offset($offset) {
    $this->offset = $offset;
  }

  /**
   * Create a new grouping for the WHERE or HAVING clause.
   *
   * @param $type
   *   Either 'AND' or 'OR'. All items within this group will be added
   *   to the WHERE clause with this logical operator.
   * @param $group
   *   An ID to use for this group. If unspecified, an ID will be generated.
   * @param $where
   *   'where' or 'having'.
   *
   * @return $group
   *   The group ID generated.
   */
  function set_where_group($type = 'AND', $group = NULL, $where = 'where') {

    // Set an alias.
    $groups =& $this->{$where};
    if (!isset($group)) {
      $group = empty($groups) ? 1 : max(array_keys($groups)) + 1;
    }

    // Create an empty group
    if (empty($groups[$group])) {
      $groups[$group] = array(
        'conditions' => array(),
        'args' => array(),
      );
    }
    $groups[$group]['type'] = strtoupper($type);
    return $group;
  }

  /**
   * Control how all WHERE and HAVING groups are put together.
   *
   * @param $type
   *   Either 'AND' or 'OR'
   */
  function set_group_operator($type = 'AND') {
    $this->group_operator = strtoupper($type);
  }

  /**
   * Loads all entities contained in the passed-in $results.
   *.
   * If the entity belongs to the base table, then it gets stored in
   * $result->_entity. Otherwise, it gets stored in
   * $result->_relationship_entities[$relationship_id];
   *
   * Query plugins that don't support entities can leave the method empty.
   */
  function load_entities(&$results) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$definition public property Plugins's definition
PluginBase::$discovery protected property The discovery object.
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$plugin_id protected property The plugin_id.
PluginBase::$usesOptions protected property Denotes whether the plugin has an additional options form. 8
PluginBase::$view public property The top object of a view. 1
PluginBase::additionalThemeFunctions public function Provide a list of additional theme functions for the theme information page
PluginBase::buildOptionsForm public function Provide a form to edit options for this plugin. 15
PluginBase::defineOptions protected function Information about options for all kinds of purposes will be held here. @code 'option_name' => array( 14
PluginBase::destroy public function Clears a plugin. 2
PluginBase::getAvailableGlobalTokens public function Returns an array of available token replacements.
PluginBase::getDefinition public function Implements Drupal\Component\Plugin\PluginInterface::getDefinition(). Overrides PluginInspectionInterface::getDefinition
PluginBase::getPluginId public function Implements Drupal\Component\Plugin\PluginInterface::getPluginId(). Overrides PluginInspectionInterface::getPluginId
PluginBase::globalTokenForm public function Adds elements for available core tokens to a form.
PluginBase::globalTokenReplace public function Returns a string with any core tokens replaced.
PluginBase::pluginTitle public function Return the human readable name of the display.
PluginBase::setOptionDefaults protected function
PluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. 1
PluginBase::unpackOptions public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
PluginBase::usesOptions public function Returns the usesOptions property. 8
PluginBase::validate public function Validate that the plugin is correct and can be saved. 4
PluginBase::__construct public function Constructs a Plugin object. Overrides PluginBase::__construct
QueryPluginBase::$pager property A pager plugin that should be provided by the display.
QueryPluginBase::add_signature function Add a signature to the query, if such a thing is feasible. 1
QueryPluginBase::alter function Let modules modify the query just prior to finalizing it. 1
QueryPluginBase::build function Builds the necessary info to execute the query. 2
QueryPluginBase::execute function Executes the query and fills the associated view object with according values. 2
QueryPluginBase::get_aggregation_info function Get aggregation info for group by queries. 1
QueryPluginBase::init public function Overrides Drupal\views\Plugin\views\PluginBase::init(). 1
QueryPluginBase::load_entities function Loads all entities contained in the passed-in $results. . If the entity belongs to the base table, then it gets stored in $result->_entity. Otherwise, it gets stored in $result->_relationship_entities[$relationship_id]; 1
QueryPluginBase::query public function Generate a query and a countquery from all of the information supplied to the object. Overrides PluginBase::query 1
QueryPluginBase::set_group_operator function Control how all WHERE and HAVING groups are put together.
QueryPluginBase::set_limit function Set a LIMIT on the query, specifying a maximum number of results.
QueryPluginBase::set_offset function Set an OFFSET on the query, specifying a number of results to skip
QueryPluginBase::set_where_group function Create a new grouping for the WHERE or HAVING clause.
QueryPluginBase::submitOptionsForm public function Handle any special handling on the validate form. Overrides PluginBase::submitOptionsForm 1
QueryPluginBase::summaryTitle public function Returns the summary of the settings in the display. Overrides PluginBase::summaryTitle
QueryPluginBase::validateOptionsForm public function Validate the options form. Overrides PluginBase::validateOptionsForm