Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ViewsSearchQuery.php

function ViewsSearchQuery::conditionReplaceString

Replaces the original condition with a custom one from views recursively.

Parameters

string $search: The searched value.

string $replace: The value which replaces the search value.

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.

File

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

Class

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

Namespace

Drupal\search

Code

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']);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal