function StringDatabaseStorage::checkVersion

Same name in other branches
  1. 9 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::checkVersion()
  2. 10 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::checkVersion()
  3. 11.x 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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.