You are here

private function LdapQuery::translateCondition 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::translateCondition()

Produces a filter condition and adds optional negation.

Parameters

string $field: LDAP attribute name.

string $value: Field value.

string $operator: Negation operator.

Return value

string LDAP filter such as (cn=Example).

1 call to LdapQuery::translateCondition()
LdapQuery::buildConditions in ldap_query/src/Plugin/views/query/LdapQuery.php
Compiles all conditions into a set of LDAP requirements.

File

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

Class

LdapQuery
Views query plugin for an SQL query.

Namespace

Drupal\ldap_query\Plugin\views\query

Code

private function translateCondition(string $field, string $value, string $operator) : string {
  if (mb_strpos($operator, '!') === 0) {
    $condition = sprintf('(!(%s=%s))', $field, Html::escape($value));
  }
  else {
    $condition = sprintf('(%s=%s)', $field, Html::escape($value));
  }
  return $condition;
}