protected function StringDatabaseStorage::dbStringUpdate in Localization update 7.2
Updates string object in the database.
Parameters
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
StringStorageException If the string is not suitable for this storage, an exception is thrown.
1 call to StringDatabaseStorage::dbStringUpdate()
- StringDatabaseStorage::save in includes/
locale/ StringDatabaseStorage.php - Implements StringStorageInterface::save().
File
- includes/
locale/ StringDatabaseStorage.php, line 455 - Definition of StringDatabaseStorage.
Class
- StringDatabaseStorage
- Defines the locale string class.
Code
protected function dbStringUpdate(StringInterface $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))) {
// Change field 'customized' into 'l10n_status'. This enables the Drupal 8
// backported code to work with the Drupal 7 style database tables.
if (isset($keys['customized'])) {
$keys['l10n_status'] = $keys['customized'];
unset($keys['customized']);
}
if (isset($values['customized'])) {
$values['l10n_status'] = $values['customized'];
unset($values['customized']);
}
return db_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(),
)));
}
}