queryParseSearchExpression example

/** * {@inheritdoc} */
  public function validateExposed(&$form, FormStateInterface $form_state) {
    if (!isset($this->options['expose']['identifier'])) {
      return;
    }

    $key = $this->options['expose']['identifier'];
    if (!$form_state->isValueEmpty($key)) {
      $this->queryParseSearchExpression($form_state->getValue($key));
      if (count($this->searchQuery->words()) == 0) {
        $form_state->setErrorByName($key$this->formatPlural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one keyword to match in the content, and punctuation is ignored.', 'You must include at least one keyword to match in the content. Keywords must be at least @count characters, and punctuation is ignored.'));
      }
    }
  }

  /** * Sets up and parses the search query. * * @param string $input * The search keywords entered by the user. */
$this->searchQuery = \Drupal::service('database.replica')->select('search_index', 'i')->extend(ViewsSearchQuery::class);
      $this->searchQuery->searchExpression($input$this->searchType);
      $this->searchQuery->publicParseSearchExpression();
    }
  }

  /** * {@inheritdoc} */
  public function query($group_by = FALSE) {
    $required = FALSE;
    $this->queryParseSearchExpression($this->argument);
    if (!isset($this->searchQuery)) {
      $required = TRUE;
    }
    else {
      $words = $this->searchQuery->words();
      if (empty($words)) {
        $required = TRUE;
      }
    }
    if ($required) {
      if ($this->operator == 'required') {
        
Home | Imprint | This part of the site doesn't use cookies.