You are here

protected function GoogleApiClientSelection::buildEntityQuery in Google API PHP Client 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/EntityReferenceSelection/GoogleApiClientSelection.php \Drupal\google_api_client\Plugin\EntityReferenceSelection\GoogleApiClientSelection::buildEntityQuery()

Builds an EntityQuery to get referenceable entities.

Parameters

string|null $match: (Optional) Text to match the label against. Defaults to NULL.

string $match_operator: (Optional) The operation the matching should be done with. Defaults to "CONTAINS".

Return value

\Drupal\Core\Entity\Query\QueryInterface The EntityQuery object with the basic conditions and sorting applied to it.

Overrides DefaultSelection::buildEntityQuery

File

src/Plugin/EntityReferenceSelection/GoogleApiClientSelection.php, line 23

Class

GoogleApiClientSelection
Provides property filter for google client entity type.

Namespace

Drupal\google_api_client\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);
  $configuration = $this
    ->getConfiguration();
  if (is_array($configuration['property']) && !empty($configuration['property'])) {
    $fields = array_keys($configuration['property']);
    foreach ($fields as $field) {
      if (is_array($configuration['property'][$field])) {
        $query
          ->condition($field, $configuration['property'][$field], 'IN');
      }
      else {
        $query
          ->condition($field, $configuration['property'][$field]);
      }
    }
  }
  return $query;
}