You are here

public function StringDatabaseStorage::save in Zircon Profile 8

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

Save string object to storage.

Parameters

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

Return value

\Drupal\locale\StringStorageInterface The called object.

Throws

\Drupal\locale\StringStorageException In case of failures, an exception is thrown.

Overrides StringStorageInterface::save

File

core/modules/locale/src/StringDatabaseStorage.php, line 119
Contains \Drupal\locale\StringDatabaseStorage.

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;
}