You are here

class Query in Search API 8

Provides a standard implementation for a Search API query.

Hierarchy

Expanded class hierarchy of Query

6 files declare their use of Query
AddHierarchyTest.php in tests/src/Kernel/Processor/AddHierarchyTest.php
NumberFieldBoostTest.php in tests/src/Kernel/Processor/NumberFieldBoostTest.php
QueryHelper.php in src/Utility/QueryHelper.php
QueryTest.php in tests/src/Kernel/System/QueryTest.php
TestItemsTrait.php in tests/src/Unit/Processor/TestItemsTrait.php

... See full list

File

src/Query/Query.php, line 25

Namespace

Drupal\search_api\Query
View source
class Query implements QueryInterface, RefinableCacheableDependencyInterface {
  use StringTranslationTrait;
  use RefinableCacheableDependencyTrait;
  use DependencySerializationTrait {
    __sleep as traitSleep;
    __wakeup as traitWakeup;
  }

  /**
   * The index on which the query will be executed.
   *
   * @var \Drupal\search_api\IndexInterface
   */
  protected $index;

  /**
   * The index's ID.
   *
   * Used when serializing, to avoid serializing the index, too.
   *
   * @var string|null
   */
  protected $indexId;

  /**
   * The search results.
   *
   * @var \Drupal\search_api\Query\ResultSetInterface
   */
  protected $results;

  /**
   * The search ID set for this query.
   *
   * @var string
   */
  protected $searchId;

  /**
   * The parse mode to use for fulltext search keys.
   *
   * @var \Drupal\search_api\ParseMode\ParseModeInterface|null
   */
  protected $parseMode;

  /**
   * The processing level for this search query.
   *
   * One of the \Drupal\search_api\Query\QueryInterface::PROCESSING_* constants.
   *
   * @var int
   */
  protected $processingLevel = self::PROCESSING_FULL;

  /**
   * The language codes which should be searched by this query.
   *
   * @var string[]|null
   */
  protected $languages;

  /**
   * The search keys.
   *
   * If NULL, this will be a filter-only search.
   *
   * @var mixed
   */
  protected $keys;

  /**
   * The unprocessed search keys, as passed to the keys() method.
   *
   * @var mixed
   */
  protected $origKeys;

  /**
   * The fulltext fields that will be searched for the keys.
   *
   * @var array
   */
  protected $fields;

  /**
   * The root condition group associated with this query.
   *
   * @var \Drupal\search_api\Query\ConditionGroupInterface
   */
  protected $conditionGroup;

  /**
   * The sorts associated with this query.
   *
   * @var array
   */
  protected $sorts = [];

  /**
   * Information about whether the query has been aborted or not.
   *
   * @var \Drupal\Component\Render\MarkupInterface|string|true|null
   */
  protected $aborted;

  /**
   * Options configuring this query.
   *
   * @var array
   */
  protected $options;

  /**
   * The tags set on this query.
   *
   * @var string[]
   */
  protected $tags = [];

  /**
   * Flag for whether preExecute() was already called for this query.
   *
   * @var bool
   */
  protected $preExecuteRan = FALSE;

  /**
   * Flag for whether execute() was already called for this query.
   *
   * @var bool
   */
  protected $executed = FALSE;

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface|null
   */
  protected $moduleHandler;

  /**
   * The event dispatcher.
   *
   * @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher|null
   */
  protected $eventDispatcher;

  /**
   * The parse mode manager.
   *
   * @var \Drupal\search_api\ParseMode\ParseModePluginManager|null
   */
  protected $parseModeManager;

  /**
   * The display plugin manager.
   *
   * @var \Drupal\search_api\Display\DisplayPluginManagerInterface|null
   */
  protected $displayPluginManager;

  /**
   * The result cache service.
   *
   * @var \Drupal\search_api\Utility\QueryHelperInterface|null
   */
  protected $queryHelper;

  /**
   * The original query before preprocessing.
   *
   * @var static|null
   */
  protected $originalQuery;

  /**
   * Constructs a Query object.
   *
   * @param \Drupal\search_api\IndexInterface $index
   *   The index the query should be executed on.
   * @param array $options
   *   (optional) Associative array of options configuring this query. See
   *   \Drupal\search_api\Query\QueryInterface::setOption() for a list of
   *   options that are recognized by default.
   *
   * @throws \Drupal\search_api\SearchApiException
   *   Thrown if a search on that index (or with those options) won't be
   *   possible.
   */
  public function __construct(IndexInterface $index, array $options = []) {
    if (!$index
      ->status()) {
      $index_label = $index
        ->label();
      throw new SearchApiException("Can't search on index '{$index_label}' which is disabled.");
    }
    $this->index = $index;
    $this->results = new ResultSet($this);
    $this->options = $options;
    $this->conditionGroup = $this
      ->createConditionGroup('AND');
  }

  /**
   * {@inheritdoc}
   */
  public static function create(IndexInterface $index, array $options = []) {
    return new static($index, $options);
  }

  /**
   * Retrieves the module handler.
   *
   * @return \Drupal\Core\Extension\ModuleHandlerInterface
   *   The module handler.
   */
  public function getModuleHandler() {
    return $this->moduleHandler ?: \Drupal::moduleHandler();
  }

  /**
   * Sets the module handler.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The new module handler.
   *
   * @return $this
   */
  public function setModuleHandler(ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
    return $this;
  }

  /**
   * Retrieves the event dispatcher.
   *
   * @return \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher
   *   The event dispatcher.
   */
  public function getEventDispatcher() {
    return $this->eventDispatcher ?: \Drupal::service('event_dispatcher');
  }

  /**
   * Sets the event dispatcher.
   *
   * @param \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher
   *   The new event dispatcher.
   *
   * @return $this
   */
  public function setEventDispatcher(ContainerAwareEventDispatcher $event_dispatcher) {
    $this->eventDispatcher = $event_dispatcher;
    return $this;
  }

  /**
   * Retrieves the parse mode manager.
   *
   * @return \Drupal\search_api\ParseMode\ParseModePluginManager
   *   The parse mode manager.
   */
  public function getParseModeManager() {
    return $this->parseModeManager ?: \Drupal::service('plugin.manager.search_api.parse_mode');
  }

  /**
   * Sets the parse mode manager.
   *
   * @param \Drupal\search_api\ParseMode\ParseModePluginManager $parse_mode_manager
   *   The new parse mode manager.
   *
   * @return $this
   */
  public function setParseModeManager(ParseModePluginManager $parse_mode_manager) {
    $this->parseModeManager = $parse_mode_manager;
    return $this;
  }

  /**
   * Retrieves the display plugin manager.
   *
   * @return \Drupal\search_api\Display\DisplayPluginManagerInterface
   *   The display plugin manager.
   */
  public function getDisplayPluginManager() {
    return $this->displayPluginManager ?: \Drupal::service('plugin.manager.search_api.display');
  }

  /**
   * Sets the display plugin manager.
   *
   * @param \Drupal\search_api\Display\DisplayPluginManagerInterface $display_plugin_manager
   *   The new display plugin manager.
   *
   * @return $this
   */
  public function setDisplayPluginManager(DisplayPluginManagerInterface $display_plugin_manager) {
    $this->displayPluginManager = $display_plugin_manager;
    return $this;
  }

  /**
   * Retrieves the query helper.
   *
   * @return \Drupal\search_api\Utility\QueryHelperInterface
   *   The query helper.
   */
  public function getQueryHelper() {
    return $this->queryHelper ?: \Drupal::service('search_api.query_helper');
  }

  /**
   * Sets the query helper.
   *
   * @param \Drupal\search_api\Utility\QueryHelperInterface $query_helper
   *   The new query helper.
   *
   * @return $this
   */
  public function setQueryHelper(QueryHelperInterface $query_helper) {
    $this->queryHelper = $query_helper;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getSearchId($generate = TRUE) {
    if ($generate && !isset($this->searchId)) {
      static $num = 0;
      $this->searchId = 'search_' . ++$num;
    }
    return $this->searchId;
  }

  /**
   * {@inheritdoc}
   */
  public function setSearchId($search_id) {
    $this->searchId = $search_id;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getDisplayPlugin() {
    $display_manager = $this
      ->getDisplayPluginManager();
    if (isset($this->searchId) && $display_manager
      ->hasDefinition($this->searchId)) {
      return $display_manager
        ->createInstance($this->searchId);
    }
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getParseMode() {
    if (!$this->parseMode) {
      $this->parseMode = $this
        ->getParseModeManager()
        ->createInstance('terms');
    }
    return $this->parseMode;
  }

  /**
   * {@inheritdoc}
   */
  public function setParseMode(ParseModeInterface $parse_mode) {
    $this->parseMode = $parse_mode;
    if (is_scalar($this->origKeys)) {
      $this->keys = $parse_mode
        ->parseInput($this->origKeys);
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getLanguages() {
    return $this->languages;
  }

  /**
   * {@inheritdoc}
   */
  public function setLanguages(array $languages = NULL) {
    $this->languages = $languages !== NULL ? array_values($languages) : NULL;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function createConditionGroup($conjunction = 'AND', array $tags = []) {
    return new ConditionGroup($conjunction, $tags);
  }

  /**
   * {@inheritdoc}
   */
  public function keys($keys = NULL) {
    $this->origKeys = $keys;
    if (is_scalar($keys)) {
      $this->keys = $this
        ->getParseMode()
        ->parseInput("{$keys}");
    }
    else {
      $this->keys = $keys;
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setFulltextFields(array $fields = NULL) {
    $this->fields = $fields;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function addConditionGroup(ConditionGroupInterface $condition_group) {
    $this->conditionGroup
      ->addConditionGroup($condition_group);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function addCondition($field, $value, $operator = '=') {
    $this->conditionGroup
      ->addCondition($field, $value, $operator);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function sort($field, $order = self::SORT_ASC) {
    $order = strtoupper(trim($order));
    $order = $order == self::SORT_DESC ? self::SORT_DESC : self::SORT_ASC;
    if (!isset($this->sorts[$field])) {
      $this->sorts[$field] = $order;
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function range($offset = NULL, $limit = NULL) {
    $this->options['offset'] = $offset;
    $this->options['limit'] = $limit;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getProcessingLevel() {
    return $this->processingLevel;
  }

  /**
   * {@inheritdoc}
   */
  public function setProcessingLevel($level) {
    $this->processingLevel = $level;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function abort($error_message = NULL) {
    $this->aborted = $error_message ?? TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function wasAborted() {
    return $this->aborted !== NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getAbortMessage() {
    return !is_bool($this->aborted) ? $this->aborted : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function execute() {
    if ($this
      ->hasExecuted()) {
      return $this->results;
    }
    $this->executed = TRUE;

    // Check for aborted status both before and after calling preExecute().
    if ($this
      ->shouldAbort()) {
      return $this->results;
    }

    // Prepare the query for execution by the server.
    $this
      ->preExecute();
    if ($this
      ->shouldAbort()) {
      return $this->results;
    }

    // Execute query.
    $this->index
      ->getServerInstance()
      ->search($this);

    // Postprocess the search results.
    $this
      ->postExecute();
    return $this->results;
  }

  /**
   * Determines whether the query should be aborted.
   *
   * Also prepares the result set if the query should be aborted.
   *
   * @return bool
   *   TRUE if the query should be aborted, FALSE otherwise.
   */
  protected function shouldAbort() {
    if (!$this
      ->wasAborted() && $this->languages !== []) {
      return FALSE;
    }
    if (!$this->originalQuery) {
      $this->originalQuery = clone $this;
    }
    $this
      ->postExecute();
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function preExecute() {

    // Make sure to only execute this once per query, and not for queries with
    // the "none" processing level.
    if (!$this->preExecuteRan) {
      $this->originalQuery = clone $this;
      $this->originalQuery->executed = FALSE;
      $this->preExecuteRan = TRUE;
      if ($this->processingLevel == self::PROCESSING_NONE) {
        return;
      }

      // Preprocess query.
      $this->index
        ->preprocessSearchQuery($this);

      // Let modules alter the query.
      $event_base_name = SearchApiEvents::QUERY_PRE_EXECUTE;
      $event = new QueryPreExecuteEvent($this);
      $this
        ->getEventDispatcher()
        ->dispatch($event_base_name, $event);
      $hooks = [
        'search_api_query',
      ];
      foreach ($this->tags as $tag) {
        $hooks[] = "search_api_query_{$tag}";
        $event_name = "{$event_base_name}.{$tag}";
        $event = new QueryPreExecuteEvent($this);
        $this
          ->getEventDispatcher()
          ->dispatch($event_name, $event);
      }
      $description = 'This hook is deprecated in search_api:8.x-1.14 and is removed from search_api:2.0.0. Please use the "search_api.query_pre_execute" event instead. See https://www.drupal.org/node/3059866';
      $this
        ->getModuleHandler()
        ->alterDeprecated($description, $hooks, $this);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function postExecute() {
    if ($this->processingLevel == self::PROCESSING_NONE) {
      return;
    }

    // Postprocess results.
    $this->index
      ->postprocessSearchResults($this->results);

    // Let modules alter the results.
    $event_base_name = SearchApiEvents::PROCESSING_RESULTS;
    $event = new ProcessingResultsEvent($this->results);
    $this
      ->getEventDispatcher()
      ->dispatch($event_base_name, $event);
    $this->results = $event
      ->getResults();
    $hooks = [
      'search_api_results',
    ];
    foreach ($this->tags as $tag) {
      $hooks[] = "search_api_results_{$tag}";
      $event = new ProcessingResultsEvent($this->results);
      $this
        ->getEventDispatcher()
        ->dispatch("{$event_base_name}.{$tag}", $event);
      $this->results = $event
        ->getResults();
    }
    $description = 'This hook is deprecated in search_api:8.x-1.14 and is removed from search_api:2.0.0. Please use the "search_api.processing_results" event instead. See https://www.drupal.org/node/3059866';
    $this
      ->getModuleHandler()
      ->alterDeprecated($description, $hooks, $this->results);

    // Store the results in the static cache.
    $this
      ->getQueryHelper()
      ->addResults($this->results);
  }

  /**
   * {@inheritdoc}
   */
  public function hasExecuted() {
    return $this->executed;
  }

  /**
   * {@inheritdoc}
   */
  public function getResults() {
    return $this->results;
  }

  /**
   * {@inheritdoc}
   */
  public function getIndex() {
    return $this->index;
  }

  /**
   * {@inheritdoc}
   */
  public function &getKeys() {
    return $this->keys;
  }

  /**
   * {@inheritdoc}
   */
  public function getOriginalKeys() {
    return $this->origKeys;
  }

  /**
   * {@inheritdoc}
   */
  public function &getFulltextFields() {
    return $this->fields;
  }

  /**
   * {@inheritdoc}
   */
  public function getConditionGroup() {
    return $this->conditionGroup;
  }

  /**
   * {@inheritdoc}
   */
  public function &getSorts() {
    return $this->sorts;
  }

  /**
   * {@inheritdoc}
   */
  public function getOption($name, $default = NULL) {
    return array_key_exists($name, $this->options) ? $this->options[$name] : $default;
  }

  /**
   * {@inheritdoc}
   */
  public function setOption($name, $value) {
    $old = $this
      ->getOption($name);
    $this->options[$name] = $value;
    return $old;
  }

  /**
   * {@inheritdoc}
   */
  public function &getOptions() {
    return $this->options;
  }

  /**
   * {@inheritdoc}
   */
  public function addTag($tag) {
    $this->tags[$tag] = $tag;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function hasTag($tag) {
    return isset($this->tags[$tag]);
  }

  /**
   * {@inheritdoc}
   */
  public function hasAllTags() {
    return !array_diff_key(array_flip(func_get_args()), $this->tags);
  }

  /**
   * {@inheritdoc}
   */
  public function hasAnyTag() {
    return (bool) array_intersect_key(array_flip(func_get_args()), $this->tags);
  }

  /**
   * {@inheritdoc}
   */
  public function &getTags() {
    return $this->tags;
  }

  /**
   * {@inheritdoc}
   */
  public function getOriginalQuery() {
    return $this->originalQuery ?: clone $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    $contexts = $this->cacheContexts;
    foreach ($this
      ->getIndex()
      ->getDatasources() as $datasource) {
      $contexts = Cache::mergeContexts($datasource
        ->getListCacheContexts(), $contexts);
    }
    return $contexts;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    $tags = $this->cacheTags;

    // If the configuration of the search index changes we should invalidate the
    // views that show results from this index.
    $index_tags = $this
      ->getIndex()
      ->getCacheTagsToInvalidate();
    $tags = Cache::mergeTags($index_tags, $tags);
    return $tags;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return $this->cacheMaxAge;
  }

  /**
   * Implements the magic __clone() method to properly clone nested objects.
   */
  public function __clone() {
    $this->results = $this
      ->getResults()
      ->getCloneForQuery($this);
    $this->conditionGroup = clone $this->conditionGroup;
    if ($this->originalQuery) {
      $this->originalQuery = clone $this->originalQuery;
    }
    if ($this->parseMode) {
      $this->parseMode = clone $this->parseMode;
    }
  }

  /**
   * Implements the magic __sleep() method to avoid serializing the index.
   */
  public function __sleep() {
    $this->indexId = $this->index
      ->id();
    $keys = $this
      ->traitSleep();
    return array_diff($keys, [
      'index',
    ]);
  }

  /**
   * Implements the magic __wakeup() method to reload the query's index.
   */
  public function __wakeup() {
    if (!isset($this->index) && !empty($this->indexId) && \Drupal::hasContainer() && \Drupal::getContainer()
      ->has('entity_type.manager')) {
      $this->index = \Drupal::entityTypeManager()
        ->getStorage('search_api_index')
        ->load($this->indexId);
      $this->indexId = NULL;
    }
    $this
      ->traitWakeup();
  }

  /**
   * Implements the magic __toString() method to simplify debugging.
   */
  public function __toString() {
    $ret = 'Index: ' . $this->index
      ->id() . "\n";
    $ret .= 'Keys: ' . str_replace("\n", "\n  ", var_export($this->origKeys, TRUE)) . "\n";
    if (isset($this->keys)) {
      $ret .= 'Parsed keys: ' . str_replace("\n", "\n  ", var_export($this->keys, TRUE)) . "\n";
      $ret .= 'Searched fields: ' . (isset($this->fields) ? implode(', ', $this->fields) : '[ALL]') . "\n";
    }
    if (isset($this->languages)) {
      $ret .= 'Searched languages: ' . implode(', ', $this->languages) . "\n";
    }
    if ($conditions = (string) $this->conditionGroup) {
      $conditions = str_replace("\n", "\n  ", $conditions);
      $ret .= "Conditions:\n  {$conditions}\n";
    }
    if ($this->sorts) {
      $sorts = [];
      foreach ($this->sorts as $field => $order) {
        $sorts[] = "{$field} {$order}";
      }
      $ret .= 'Sorting: ' . implode(', ', $sorts) . "\n";
    }
    $options = $this
      ->sanitizeOptions($this->options);
    $options = str_replace("\n", "\n  ", var_export($options, TRUE));
    $ret .= 'Options: ' . $options . "\n";
    return $ret;
  }

  /**
   * Sanitizes an array of options in a way that plays nice with var_export().
   *
   * @param array $options
   *   An array of options.
   *
   * @return array
   *   The sanitized options.
   */
  protected function sanitizeOptions(array $options) {
    foreach ($options as $key => $value) {
      if (is_object($value)) {
        $options[$key] = 'object (' . get_class($value) . ')';
      }
      elseif (is_array($value)) {
        $options[$key] = $this
          ->sanitizeOptions($value);
      }
    }
    return $options;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function Aliased as: traitWakeup 2
Query::$aborted protected property Information about whether the query has been aborted or not.
Query::$conditionGroup protected property The root condition group associated with this query.
Query::$displayPluginManager protected property The display plugin manager.
Query::$eventDispatcher protected property The event dispatcher.
Query::$executed protected property Flag for whether execute() was already called for this query.
Query::$fields protected property The fulltext fields that will be searched for the keys.
Query::$index protected property The index on which the query will be executed.
Query::$indexId protected property The index's ID.
Query::$keys protected property The search keys.
Query::$languages protected property The language codes which should be searched by this query.
Query::$moduleHandler protected property The module handler.
Query::$options protected property Options configuring this query.
Query::$originalQuery protected property The original query before preprocessing.
Query::$origKeys protected property The unprocessed search keys, as passed to the keys() method.
Query::$parseMode protected property The parse mode to use for fulltext search keys.
Query::$parseModeManager protected property The parse mode manager.
Query::$preExecuteRan protected property Flag for whether preExecute() was already called for this query.
Query::$processingLevel protected property The processing level for this search query.
Query::$queryHelper protected property The result cache service.
Query::$results protected property The search results.
Query::$searchId protected property The search ID set for this query.
Query::$sorts protected property The sorts associated with this query.
Query::$tags protected property The tags set on this query.
Query::abort public function Aborts this query. Overrides QueryInterface::abort
Query::addCondition public function Adds a new ($field $operator $value) condition. Overrides ConditionSetInterface::addCondition
Query::addConditionGroup public function Adds a nested condition group. Overrides ConditionSetInterface::addConditionGroup
Query::addTag public function Sets the given tag on this query. Overrides QueryInterface::addTag
Query::create public static function Instantiates a new instance of this query class. Overrides QueryInterface::create
Query::createConditionGroup public function Creates a new condition group to use with this query object. Overrides QueryInterface::createConditionGroup
Query::execute public function Executes this search query. Overrides QueryInterface::execute
Query::getAbortMessage public function Retrieves the error message explaining why this query was aborted, if any. Overrides QueryInterface::getAbortMessage
Query::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
Query::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
Query::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
Query::getConditionGroup public function Retrieves the condition group object associated with this search query. Overrides QueryInterface::getConditionGroup
Query::getDisplayPlugin public function Retrieves the search display associated with this query (if any). Overrides QueryInterface::getDisplayPlugin
Query::getDisplayPluginManager public function Retrieves the display plugin manager.
Query::getEventDispatcher public function Retrieves the event dispatcher.
Query::getFulltextFields public function Retrieves the fulltext fields that will be searched for the search keys. Overrides QueryInterface::getFulltextFields
Query::getIndex public function Retrieves the index associated with this search. Overrides QueryInterface::getIndex
Query::getKeys public function Retrieves the search keys for this query. Overrides QueryInterface::getKeys
Query::getLanguages public function Retrieves the languages that will be searched by this query. Overrides QueryInterface::getLanguages
Query::getModuleHandler public function Retrieves the module handler.
Query::getOption public function Retrieves an option set on this search query. Overrides QueryInterface::getOption
Query::getOptions public function Retrieves all options set for this search query. Overrides QueryInterface::getOptions
Query::getOriginalKeys public function Retrieves the unparsed search keys for this query as originally entered. Overrides QueryInterface::getOriginalKeys
Query::getOriginalQuery public function Retrieves the original version of the query, before preprocessing occurred. Overrides QueryInterface::getOriginalQuery
Query::getParseMode public function Retrieves the parse mode. Overrides QueryInterface::getParseMode
Query::getParseModeManager public function Retrieves the parse mode manager.
Query::getProcessingLevel public function Retrieves the processing level for this query. Overrides QueryInterface::getProcessingLevel
Query::getQueryHelper public function Retrieves the query helper.
Query::getResults public function Retrieves this query's result set. Overrides QueryInterface::getResults
Query::getSearchId public function Retrieves the search ID. Overrides QueryInterface::getSearchId
Query::getSorts public function Retrieves the sorts set for this query. Overrides QueryInterface::getSorts
Query::getTags public function Retrieves the tags set on this query. Overrides QueryInterface::getTags
Query::hasAllTags public function Determines whether this query has all the given tags set on it. Overrides QueryInterface::hasAllTags
Query::hasAnyTag public function Determines whether this query has any of the given tags set on it. Overrides QueryInterface::hasAnyTag
Query::hasExecuted public function Determines whether this query has been executed already. Overrides QueryInterface::hasExecuted
Query::hasTag public function Checks whether a certain tag was set on this search query. Overrides QueryInterface::hasTag
Query::keys public function Sets the keys to search for. Overrides QueryInterface::keys
Query::postExecute public function Postprocesses the search results before they are returned. Overrides QueryInterface::postExecute
Query::preExecute public function Prepares the query object for the search. Overrides QueryInterface::preExecute
Query::range public function Adds a range of results to return. Overrides QueryInterface::range
Query::sanitizeOptions protected function Sanitizes an array of options in a way that plays nice with var_export().
Query::setDisplayPluginManager public function Sets the display plugin manager.
Query::setEventDispatcher public function Sets the event dispatcher.
Query::setFulltextFields public function Sets the fields that will be searched for the search keys. Overrides QueryInterface::setFulltextFields
Query::setLanguages public function Sets the languages that should be searched by this query. Overrides QueryInterface::setLanguages
Query::setModuleHandler public function Sets the module handler.
Query::setOption public function Sets an option for this search query. Overrides QueryInterface::setOption
Query::setParseMode public function Sets the parse mode. Overrides QueryInterface::setParseMode
Query::setParseModeManager public function Sets the parse mode manager.
Query::setProcessingLevel public function Sets the processing level for this query. Overrides QueryInterface::setProcessingLevel
Query::setQueryHelper public function Sets the query helper.
Query::setSearchId public function Sets the search ID. Overrides QueryInterface::setSearchId
Query::shouldAbort protected function Determines whether the query should be aborted.
Query::sort public function Adds a sort directive to this search query. Overrides QueryInterface::sort
Query::wasAborted public function Determines whether this query was aborted. Overrides QueryInterface::wasAborted
Query::__clone public function Implements the magic __clone() method to properly clone nested objects.
Query::__construct public function Constructs a Query object.
Query::__sleep public function Implements the magic __sleep() method to avoid serializing the index.
Query::__toString public function Implements the magic __toString() method to simplify debugging.
Query::__wakeup public function Implements the magic __wakeup() method to reload the query's index.
QueryInterface::PROCESSING_BASIC constant Constant representing a search with only basic processing.
QueryInterface::PROCESSING_FULL constant Constant representing a search with normal/full processing.
QueryInterface::PROCESSING_NONE constant Constant representing a completely unprocessed search.
QueryInterface::SORT_ASC constant Constant representing ascending sorting.
QueryInterface::SORT_DESC constant Constant representing descending sorting.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.