You are here

public static function Importer::lookUpSynonym in Search API Synonym 8

Look up synonym.

Parameters

string $word: The source word we add the synonym for.

string $type: Synonym type.

string $langcode: Language code.

Return value

int Entity id for the found synonym.

1 call to Importer::lookUpSynonym()
Importer::createSynonym in src/Import/Importer.php
Create / update a synonym.

File

src/Import/Importer.php, line 266

Class

Importer
Importer class.

Namespace

Drupal\search_api_synonym\Import

Code

public static function lookUpSynonym($word, $type, $langcode) {
  $query = \Drupal::database()
    ->select('search_api_synonym', 's');
  $query
    ->fields('s', [
    'sid',
  ]);
  $query
    ->condition('s.type', $type);
  $query
    ->condition('s.word', $word, 'LIKE');
  $query
    ->condition('s.langcode', $langcode);
  $query
    ->range(0, 1);
  return (int) $query
    ->execute()
    ->fetchField(0);
}