3 namespace Drupal\search;
5 use Drupal\Core\Database\Query\Condition;
8 * Extends the core SearchQuery to be able to gets its protected values.
10 class ViewsSearchQuery extends SearchQuery {
13 * Returns the conditions property.
16 * The query conditions.
18 public function &conditions() {
19 return $this->conditions;
23 * Returns the words property.
26 * The positive search keywords.
28 public function words() {
33 * Returns the simple property.
36 * TRUE if it is a simple query, and FALSE if it is complicated (phrases
39 public function simple() {
44 * Returns the matches property.
47 * The number of matches needed.
49 public function matches() {
50 return $this->matches;
54 * Executes and returns the protected parseSearchExpression method.
56 public function publicParseSearchExpression() {
57 return $this->parseSearchExpression();
61 * Replaces the original condition with a custom one from views recursively.
63 * @param string $search
65 * @param string $replace
66 * The value which replaces the search value.
67 * @param array $condition
68 * The query conditions array in which the string is replaced. This is an
69 * item from a \Drupal\Core\Database\Query\Condition::conditions array,
70 * which must have a 'field' element.
72 public function conditionReplaceString($search, $replace, &$condition) {
73 if ($condition['field'] instanceof Condition) {
74 $conditions =& $condition['field']->conditions();
75 foreach ($conditions as $key => &$subcondition) {
76 if (is_numeric($key)) {
77 // As conditions can be nested, the function has to be called
79 $this->conditionReplaceString($search, $replace, $subcondition);
84 $condition['field'] = str_replace($search, $replace, $condition['field']);