protected function StringDatabaseStorage::dbStringUpdate

Updates string object in the database.

Parameters

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

Return value

bool|int If the record update failed, returns FALSE. If it succeeded, returns SAVED_NEW or SAVED_UPDATED.

Throws

Drupal\locale\StringStorageException If the string is not suitable for this storage, an exception is thrown.

1 call to StringDatabaseStorage::dbStringUpdate()
StringDatabaseStorage::save in drupal/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php
Implements Drupal\locale\StringStorageInterface::save().

File

drupal/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php, line 498
Definition of Drupal\locale\StringDatabaseStorage.

Class

StringDatabaseStorage
Defines the locale string class.

Namespace

Drupal\locale

Code

protected function dbStringUpdate($string) {
  if ($string
    ->isSource()) {
    $values = $string
      ->getValues(array(
      'source',
      'context',
      'version',
    ));
  }
  elseif ($string
    ->isTranslation()) {
    $values = $string
      ->getValues(array(
      'translation',
      'customized',
    ));
  }
  if (!empty($values) && ($keys = $this
    ->dbStringKeys($string))) {
    return $this->connection
      ->merge($this
      ->dbStringTable($string), $this->options)
      ->key($keys)
      ->fields($values)
      ->execute();
  }
  else {
    throw new StringStorageException(format_string('The string cannot be updated: @string', array(
      '@string' => $string
        ->getString(),
    )));
  }
}