Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 63
CRAP
0.00% covered (danger)
0.00%
0 / 165
SelectExtender
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 63
4422
0.00% covered (danger)
0.00%
0 / 165
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 uniqueIdentifier
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 nextPlaceholder
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 addTag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 hasTag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 hasAllTags
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 hasAnyTag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 addMetaData
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 getMetaData
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 condition
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 conditions
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 arguments
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 where
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 compile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 compiled
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 havingCondition
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 havingConditions
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 havingArguments
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 having
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 havingCompile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 havingIsNull
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 havingIsNotNull
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 havingExists
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 havingNotExists
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 extend
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 getFields
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getExpressions
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getOrderBy
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getGroupBy
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getTables
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getUnion
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 escapeLike
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 escapeField
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 getArguments
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 isPrepared
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 preExecute
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 execute
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 distinct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 addField
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 fields
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 addExpression
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 join
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 innerJoin
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 leftJoin
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 rightJoin
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 addJoin
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 orderBy
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 orderRandom
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 range
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 union
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 groupBy
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 forUpdate
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 countQuery
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 isNull
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 isNotNull
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 exists
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 notExists
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 __toString
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 __clone
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 __call
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 8
 conditionGroupFactory
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 andConditionGroup
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 orConditionGroup
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
<?php
/**
 * @file
 * Contains \Drupal\Core\Database\Query\SelectExtender.
 */
namespace Drupal\Core\Database\Query;
use Drupal\Core\Database\Connection;
/**
 * The base extender class for Select queries.
 */
class SelectExtender implements SelectInterface {
  /**
   * The Select query object we are extending/decorating.
   *
   * @var \Drupal\Core\Database\Query\SelectInterface
   */
  protected $query;
  /**
   * The connection object on which to run this query.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $connection;
  /**
   * A unique identifier for this query object.
   */
  protected $uniqueIdentifier;
  /**
   * The placeholder counter.
   */
  protected $placeholder = 0;
  public function __construct(SelectInterface $query, Connection $connection) {
    $this->uniqueIdentifier = uniqid('', TRUE);
    $this->query = $query;
    $this->connection = $connection;
  }
  /**
   * {@inheritdoc}
   */
  public function uniqueIdentifier() {
    return $this->uniqueIdentifier;
  }
  /**
   * {@inheritdoc}
   */
  public function nextPlaceholder() {
    return $this->placeholder++;
  }
  /**
   * {@inheritdoc}
   */
  public function addTag($tag) {
    $this->query->addTag($tag);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function hasTag($tag) {
    return $this->query->hasTag($tag);
  }
  /**
   * {@inheritdoc}
   */
  public function hasAllTags() {
    return call_user_func_array(array($this->query, 'hasAllTags'), func_get_args());
  }
  /**
   * {@inheritdoc}
   */
  public function hasAnyTag() {
    return call_user_func_array(array($this->query, 'hasAnyTag'), func_get_args());
  }
  /**
   * {@inheritdoc}
   */
  public function addMetaData($key, $object) {
    $this->query->addMetaData($key, $object);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function getMetaData($key) {
    return $this->query->getMetaData($key);
  }
  /**
   * {@inheritdoc}
   */
  public function condition($field, $value = NULL, $operator = '=') {
    $this->query->condition($field, $value, $operator);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function &conditions() {
    return $this->query->conditions();
  }
  /**
   * {@inheritdoc}
   */
  public function arguments() {
    return $this->query->arguments();
  }
  /**
   * {@inheritdoc}
   */
  public function where($snippet, $args = array()) {
    $this->query->where($snippet, $args);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function compile(Connection $connection, PlaceholderInterface $queryPlaceholder) {
    return $this->query->compile($connection, $queryPlaceholder);
  }
  /**
   * {@inheritdoc}
   */
  public function compiled() {
    return $this->query->compiled();
  }
  /**
   * {@inheritdoc}
   */
  public function havingCondition($field, $value = NULL, $operator = '=') {
    $this->query->havingCondition($field, $value, $operator);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function &havingConditions() {
    return $this->query->havingConditions();
  }
  /**
   * {@inheritdoc}
   */
  public function havingArguments() {
    return $this->query->havingArguments();
  }
  /**
   * {@inheritdoc}
   */
  public function having($snippet, $args = array()) {
    $this->query->having($snippet, $args);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function havingCompile(Connection $connection) {
    return $this->query->havingCompile($connection);
  }
  /**
   * {@inheritdoc}
   */
  public function havingIsNull($field) {
    $this->query->havingIsNull($field);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function havingIsNotNull($field) {
    $this->query->havingIsNotNull($field);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function havingExists(SelectInterface $select) {
    $this->query->havingExists($select);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function havingNotExists(SelectInterface $select) {
    $this->query->havingNotExists($select);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function extend($extender_name) {
    $class = $this->connection->getDriverClass($extender_name);
    return new $class($this, $this->connection);
  }
  /* Alter accessors to expose the query data to alter hooks. */
  /**
   * {@inheritdoc}
   */
  public function &getFields() {
    return $this->query->getFields();
  }
  /**
   * {@inheritdoc}
   */
  public function &getExpressions() {
    return $this->query->getExpressions();
  }
  /**
   * {@inheritdoc}
   */
  public function &getOrderBy() {
    return $this->query->getOrderBy();
  }
  /**
   * {@inheritdoc}
   */
  public function &getGroupBy() {
    return $this->query->getGroupBy();
  }
  /**
   * {@inheritdoc}
   */
  public function &getTables() {
    return $this->query->getTables();
  }
  /**
   * {@inheritdoc}
   */
  public function &getUnion() {
    return $this->query->getUnion();
  }
  /**
   * {@inheritdoc}
   */
  public function escapeLike($string) {
    return $this->query->escapeLike($string);
  }
  /**
   * {@inheritdoc}
   */
  public function escapeField($string) {
    $this->query->escapeField($string);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function getArguments(PlaceholderInterface $queryPlaceholder = NULL) {
    return $this->query->getArguments($queryPlaceholder);
  }
  /**
   * {@inheritdoc}
   */
  public function isPrepared() {
    return $this->query->isPrepared();
  }
  /**
   * {@inheritdoc}
   */
  public function preExecute(SelectInterface $query = NULL) {
    // If no query object is passed in, use $this.
    if (!isset($query)) {
      $query = $this;
    }
    return $this->query->preExecute($query);
  }
  /**
   * {@inheritdoc}
   */
  public function execute() {
    // By calling preExecute() here, we force it to preprocess the extender
    // object rather than just the base query object.  That means
    // hook_query_alter() gets access to the extended object.
    if (!$this->preExecute($this)) {
      return NULL;
    }
    return $this->query->execute();
  }
  /**
   * {@inheritdoc}
   */
  public function distinct($distinct = TRUE) {
    $this->query->distinct($distinct);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function addField($table_alias, $field, $alias = NULL) {
    return $this->query->addField($table_alias, $field, $alias);
  }
  /**
   * {@inheritdoc}
   */
  public function fields($table_alias, array $fields = array()) {
    $this->query->fields($table_alias, $fields);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function addExpression($expression, $alias = NULL, $arguments = array()) {
    return $this->query->addExpression($expression, $alias, $arguments);
  }
  /**
   * {@inheritdoc}
   */
  public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) {
    return $this->query->join($table, $alias, $condition, $arguments);
  }
  /**
   * {@inheritdoc}
   */
  public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
    return $this->query->innerJoin($table, $alias, $condition, $arguments);
  }
  /**
   * {@inheritdoc}
   */
  public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
    return $this->query->leftJoin($table, $alias, $condition, $arguments);
  }
  /**
   * {@inheritdoc}
   */
  public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) {
    return $this->query->rightJoin($table, $alias, $condition, $arguments);
  }
  /**
   * {@inheritdoc}
   */
  public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) {
    return $this->query->addJoin($type, $table, $alias, $condition, $arguments);
  }
  /**
   * {@inheritdoc}
   */
  public function orderBy($field, $direction = 'ASC') {
    $this->query->orderBy($field, $direction);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function orderRandom() {
    $this->query->orderRandom();
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function range($start = NULL, $length = NULL) {
    $this->query->range($start, $length);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function union(SelectInterface $query, $type = '') {
    $this->query->union($query, $type);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function groupBy($field) {
    $this->query->groupBy($field);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function forUpdate($set = TRUE) {
    $this->query->forUpdate($set);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function countQuery() {
    return $this->query->countQuery();
  }
  /**
   * {@inheritdoc}
   */
  function isNull($field) {
    $this->query->isNull($field);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  function isNotNull($field) {
    $this->query->isNotNull($field);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function exists(SelectInterface $select) {
    $this->query->exists($select);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function notExists(SelectInterface $select) {
    $this->query->notExists($select);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function __toString() {
    return (string) $this->query;
  }
  /**
   * {@inheritdoc}
   */
  public function __clone() {
    $this->uniqueIdentifier = uniqid('', TRUE);
    // We need to deep-clone the query we're wrapping, which in turn may
    // deep-clone other objects.  Exciting!
    $this->query = clone($this->query);
  }
  /**
   * Magic override for undefined methods.
   *
   * If one extender extends another extender, then methods in the inner extender
   * will not be exposed on the outer extender.  That's because we cannot know
   * in advance what those methods will be, so we cannot provide wrapping
   * implementations as we do above.  Instead, we use this slower catch-all method
   * to handle any additional methods.
   */
  public function __call($method, $args) {
    $return = call_user_func_array(array($this->query, $method), $args);
    // Some methods will return the called object as part of a fluent interface.
    // Others will return some useful value.  If it's a value, then the caller
    // probably wants that value.  If it's the called object, then we instead
    // return this object.  That way we don't "lose" an extender layer when
    // chaining methods together.
    if ($return instanceof SelectInterface) {
      return $this;
    }
    else {
      return $return;
    }
  }
  /**
   * {@inheritdoc}
   */
  public function conditionGroupFactory($conjunction = 'AND') {
    return new Condition($conjunction);
  }
  /**
   * {@inheritdoc}
   */
  public function andConditionGroup() {
    return $this->conditionGroupFactory('AND');
  }
  /**
   * {@inheritdoc}
   */
  public function orConditionGroup() {
    return $this->conditionGroupFactory('OR');
  }
}