You are here

public function LdapQuery::buildConditions in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_query/src/Plugin/views/query/LdapQuery.php \Drupal\ldap_query\Plugin\views\query\LdapQuery::buildConditions()

Compiles all conditions into a set of LDAP requirements.

Return value

string|null Condition string.

1 call to LdapQuery::buildConditions()
LdapQuery::buildLdapFilter in ldap_query/src/Plugin/views/query/LdapQuery.php
Collates Views arguments and filters for a modified query.

File

ldap_query/src/Plugin/views/query/LdapQuery.php, line 266

Class

LdapQuery
Views query plugin for an SQL query.

Namespace

Drupal\ldap_query\Plugin\views\query

Code

public function buildConditions() : ?string {
  $groups = [];
  foreach ($this->where as $group) {
    if (!empty($group['conditions'])) {
      $conditions = '';
      foreach ($group['conditions'] as $clause) {
        $conditions .= $this
          ->translateCondition($clause['field'], $clause['value'], $clause['operator']);
      }
      if (count($group['conditions']) > 1) {
        $groups[] = '(' . self::LDAP_FILTER_OPERATORS[$group['type']] . $conditions . ')';
      }
      else {
        $groups[] = $conditions;
      }
    }
  }
  if (count($groups) > 1) {
    $output = '(' . self::LDAP_FILTER_OPERATORS[$this->groupOperator] . implode('', $groups) . ')';
  }
  else {
    $output = array_pop($groups);
  }
  return $output;
}