class ViewsSearchQuery

Same name in this branch
  1. 11.x core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/ViewsSearchQuery.php \Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses\ViewsSearchQuery
Same name in other branches
  1. 9 core/modules/search/src/ViewsSearchQuery.php \Drupal\search\ViewsSearchQuery
  2. 9 core/tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefakeWithAllCustomClasses/ViewsSearchQuery.php \Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\ViewsSearchQuery
  3. 8.9.x core/modules/search/src/ViewsSearchQuery.php \Drupal\search\ViewsSearchQuery
  4. 10 core/modules/search/src/ViewsSearchQuery.php \Drupal\search\ViewsSearchQuery
  5. 10 core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/ViewsSearchQuery.php \Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses\ViewsSearchQuery

Extends the core SearchQuery to be able to gets its protected values.

Hierarchy

Expanded class hierarchy of ViewsSearchQuery

3 files declare their use of ViewsSearchQuery
Search.php in core/modules/search/src/Plugin/views/filter/Search.php
Search.php in core/modules/search/src/Plugin/views/argument/Search.php
ViewsSearchQuery.php in core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/ViewsSearchQuery.php

File

core/modules/search/src/ViewsSearchQuery.php, line 10

Namespace

Drupal\search
View source
class ViewsSearchQuery extends SearchQuery {
    
    /**
     * Returns the conditions property.
     *
     * @return array
     *   The query conditions.
     */
    public function &conditions() {
        return $this->conditions;
    }
    
    /**
     * Returns the words property.
     *
     * @return array
     *   The positive search keywords.
     */
    public function words() {
        return $this->words;
    }
    
    /**
     * Returns the simple property.
     *
     * @return bool
     *   TRUE if it is a simple query, and FALSE if it is complicated (phrases
     *   or LIKE).
     */
    public function simple() {
        return $this->simple;
    }
    
    /**
     * Returns the matches property.
     *
     * @return int
     *   The number of matches needed.
     */
    public function matches() {
        return $this->matches;
    }
    
    /**
     * Executes and returns the protected parseSearchExpression method.
     */
    public function publicParseSearchExpression() {
        return $this->parseSearchExpression();
    }
    
    /**
     * Replaces the original condition with a custom one from views recursively.
     *
     * @param string $search
     *   The searched value.
     * @param string $replace
     *   The value which replaces the search value.
     * @param array $condition
     *   The query conditions array in which the string is replaced. This is an
     *   item from a \Drupal\Core\Database\Query\Condition::conditions array,
     *   which must have a 'field' element.
     */
    public function conditionReplaceString($search, $replace, &$condition) {
        if ($condition['field'] instanceof ConditionInterface) {
            $conditions =& $condition['field']->conditions();
            foreach ($conditions as $key => &$subcondition) {
                if (is_numeric($key)) {
                    // As conditions can be nested, the function has to be called
                    // recursively.
                    $this->conditionReplaceString($search, $replace, $subcondition);
                }
            }
        }
        else {
            $condition['field'] = str_replace($search, $replace, $condition['field']);
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
SearchQuery::$conditions protected property Conditions that are used for exact searches.
SearchQuery::$executedPrepare protected property Indicates whether the preparation step has been executed.
SearchQuery::$keys protected property Parsed-out positive and negative search keys.
SearchQuery::$matches protected property Indicates how many matches for a search query are necessary.
SearchQuery::$multiply protected property Multipliers for score expressions.
SearchQuery::$normalize protected property Multiplier to normalize the keyword score.
SearchQuery::$relevance_count protected property
SearchQuery::$scores protected property The word score expressions.
SearchQuery::$scoresArguments protected property Arguments for the score expressions.
SearchQuery::$searchExpression protected property The keywords and advanced search options that are entered by the user.
SearchQuery::$simple protected property Indicates whether the query conditions are simple or complex (LIKE).
SearchQuery::$status protected property A bitmap of status conditions, described in getStatus().
SearchQuery::$type protected property The type of search (search type).
SearchQuery::$words protected property Array of positive search words.
SearchQuery::addScore public function Adds a custom score expression to the search query.
SearchQuery::countQuery public function Builds the default count query for SearchQuery. Overrides SelectExtender::countQuery
SearchQuery::execute public function Executes the search. Overrides SelectExtender::execute
SearchQuery::EXPRESSIONS_IGNORED constant Indicates that part of the search expression was ignored.
SearchQuery::getStatus public function Returns the query status bitmap.
SearchQuery::LOWER_CASE_OR constant Indicates that lower-case "or" was in the search expression.
SearchQuery::NO_KEYWORD_MATCHES constant Indicates that no positive keyword matches were found.
SearchQuery::NO_POSITIVE_KEYWORDS constant Indicates no positive keywords were in the search expression.
SearchQuery::parseSearchExpression protected function Parses the search query into SQL conditions.
SearchQuery::parseWord protected function Parses a word or phrase for parseQuery().
SearchQuery::preExecute public function Overrides SelectExtender::preExecute
SearchQuery::prepareAndNormalize public function Prepares the query and calculates the normalization factor.
SearchQuery::searchExpression public function Sets the search query expression.
SelectExtender::$connection protected property The connection object on which to run this query.
SelectExtender::$placeholder protected property The placeholder counter.
SelectExtender::$query protected property The Select query object we are extending/decorating.
SelectExtender::$uniqueIdentifier protected property A unique identifier for this query object.
SelectExtender::addExpression public function Overrides SelectInterface::addExpression
SelectExtender::addField public function Overrides SelectInterface::addField
SelectExtender::addJoin public function Overrides SelectInterface::addJoin
SelectExtender::addMetaData public function Overrides AlterableInterface::addMetaData
SelectExtender::addTag public function Overrides AlterableInterface::addTag
SelectExtender::alwaysFalse public function Overrides ConditionInterface::alwaysFalse
SelectExtender::andConditionGroup public function Overrides ConditionInterface::andConditionGroup
SelectExtender::arguments public function Overrides ConditionInterface::arguments
SelectExtender::compile public function Overrides ConditionInterface::compile
SelectExtender::compiled public function Overrides ConditionInterface::compiled
SelectExtender::condition public function Overrides ConditionInterface::condition
SelectExtender::conditionGroupFactory public function Overrides ConditionInterface::conditionGroupFactory
SelectExtender::distinct public function Overrides SelectInterface::distinct
SelectExtender::escapeField public function Overrides SelectInterface::escapeField
SelectExtender::escapeLike public function Overrides SelectInterface::escapeLike
SelectExtender::exists public function Overrides ConditionInterface::exists
SelectExtender::extend public function Overrides ExtendableInterface::extend
SelectExtender::fields public function Overrides SelectInterface::fields
SelectExtender::forUpdate public function Overrides SelectInterface::forUpdate
SelectExtender::getArguments public function Overrides SelectInterface::getArguments
SelectExtender::getExpressions public function Overrides SelectInterface::getExpressions
SelectExtender::getFields public function Overrides SelectInterface::getFields
SelectExtender::getGroupBy public function Overrides SelectInterface::getGroupBy
SelectExtender::getMetaData public function Overrides AlterableInterface::getMetaData
SelectExtender::getOrderBy public function Overrides SelectInterface::getOrderBy
SelectExtender::getTables public function Overrides SelectInterface::getTables
SelectExtender::getUnion public function Overrides SelectInterface::getUnion
SelectExtender::groupBy public function Overrides SelectInterface::groupBy
SelectExtender::hasAllTags public function Overrides AlterableInterface::hasAllTags
SelectExtender::hasAnyTag public function Overrides AlterableInterface::hasAnyTag
SelectExtender::hasTag public function Overrides AlterableInterface::hasTag
SelectExtender::having public function Overrides SelectInterface::having
SelectExtender::havingArguments public function Overrides SelectInterface::havingArguments
SelectExtender::havingCompile public function Overrides SelectInterface::havingCompile
SelectExtender::havingCondition public function Overrides SelectInterface::havingCondition
SelectExtender::havingConditions public function Overrides SelectInterface::havingConditions
SelectExtender::havingExists public function Overrides SelectInterface::havingExists
SelectExtender::havingIsNotNull public function Overrides SelectInterface::havingIsNotNull
SelectExtender::havingIsNull public function Overrides SelectInterface::havingIsNull
SelectExtender::havingNotExists public function Overrides SelectInterface::havingNotExists
SelectExtender::innerJoin public function Overrides SelectInterface::innerJoin
SelectExtender::isNotNull public function Overrides ConditionInterface::isNotNull
SelectExtender::isNull public function Overrides ConditionInterface::isNull
SelectExtender::isPrepared public function Overrides SelectInterface::isPrepared
SelectExtender::join public function Overrides SelectInterface::join
SelectExtender::leftJoin public function Overrides SelectInterface::leftJoin
SelectExtender::nextPlaceholder public function Overrides PlaceholderInterface::nextPlaceholder
SelectExtender::notExists public function Overrides ConditionInterface::notExists
SelectExtender::orConditionGroup public function Overrides ConditionInterface::orConditionGroup
SelectExtender::orderBy public function Overrides SelectInterface::orderBy
SelectExtender::orderRandom public function Overrides SelectInterface::orderRandom
SelectExtender::range public function Overrides SelectInterface::range
SelectExtender::union public function Overrides SelectInterface::union
SelectExtender::uniqueIdentifier public function Overrides PlaceholderInterface::uniqueIdentifier
SelectExtender::where public function Overrides ConditionInterface::where
SelectExtender::__call public function Magic override for undefined methods.
SelectExtender::__clone public function Overrides SelectInterface::__clone
SelectExtender::__construct public function 2
SelectExtender::__toString public function Overrides SelectInterface::__toString
ViewsSearchQuery::conditionReplaceString public function Replaces the original condition with a custom one from views recursively.
ViewsSearchQuery::conditions public function Returns the conditions property. Overrides SelectExtender::conditions
ViewsSearchQuery::matches public function Returns the matches property.
ViewsSearchQuery::publicParseSearchExpression public function Executes and returns the protected parseSearchExpression method.
ViewsSearchQuery::simple public function Returns the simple property.
ViewsSearchQuery::words public function Returns the words property.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.