You are here

public function StringDatabaseStorage::findTranslation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::findTranslation()

Loads a string translation object, fast query.

This function must only be used when actually translating strings as it will have the effect of updating the string version. For other purposes the getTranslations() method should be used instead.

Parameters

array $conditions: (optional) Array with conditions that will be used to filter the strings returned and may include all of the conditions defined by getStrings().

Return value

\Drupal\locale\TranslationString|null Minimal TranslationString object if found, NULL otherwise.

Overrides StringStorageInterface::findTranslation

File

core/modules/locale/src/StringDatabaseStorage.php, line 72

Class

StringDatabaseStorage
Defines a class to store localized strings in the database.

Namespace

Drupal\locale

Code

public function findTranslation(array $conditions) {
  $values = $this
    ->dbStringSelect($conditions, [
    'translation' => TRUE,
  ])
    ->execute()
    ->fetchAssoc();
  if (!empty($values)) {
    $string = new TranslationString($values);
    $this
      ->checkVersion($string, \Drupal::VERSION);
    $string
      ->setStorage($this);
    return $string;
  }
}