You are here

protected function StringDatabaseStorage::checkVersion in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::checkVersion()
  2. 10 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::checkVersion()

Checks whether the string version matches a given version, fix it if not.

Parameters

\Drupal\locale\StringInterface $string: The string object.

string $version: Drupal version to check against.

2 calls to StringDatabaseStorage::checkVersion()
StringDatabaseStorage::findTranslation in core/modules/locale/src/StringDatabaseStorage.php
Loads a string translation object, fast query.
StringDatabaseStorage::updateLocation in core/modules/locale/src/StringDatabaseStorage.php
Update locations for string.

File

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

Class

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

Namespace

Drupal\locale

Code

protected function checkVersion($string, $version) {
  if ($string
    ->getId() && $string
    ->getVersion() != $version) {
    $string
      ->setVersion($version);
    $this->connection
      ->update('locales_source', $this->options)
      ->condition('lid', $string
      ->getId())
      ->fields([
      'version' => $version,
    ])
      ->execute();
  }
}