function StringDatabaseStorage::save

Same name in other branches
  1. 9 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::save()
  2. 8.9.x core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::save()
  3. 10 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::save()

File

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

Class

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

Namespace

Drupal\locale

Code

public function save($string) {
    if ($string->isNew()) {
        $result = $this->dbStringInsert($string);
        if ($string->isSource() && $result) {
            // Only for source strings, we set the locale identifier.
            $string->setId($result);
        }
        $string->setStorage($this);
    }
    else {
        $this->dbStringUpdate($string);
    }
    // Update locations if they come with the string.
    $this->updateLocation($string);
    return $this;
}

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