You are here

public function StringDatabaseStorage::delete in Localization update 7.2

Implements StringStorageInterface::delete().

Overrides StringStorageInterface::delete

File

includes/locale/StringDatabaseStorage.php, line 130
Definition of StringDatabaseStorage.

Class

StringDatabaseStorage
Defines the locale string class.

Code

public function delete(\StringInterface $string) {
  if ($keys = $this
    ->dbStringKeys($string)) {
    $this
      ->dbDelete('locales_target', $keys)
      ->execute();
    if ($string
      ->isSource()) {
      $this
        ->dbDelete('locales_source', $keys)
        ->execute();
      $this
        ->dbDelete('locales_location', $keys)
        ->execute();
      $string
        ->setId(NULL);
    }
  }
  else {
    throw new StringStorageException(format_string('The string cannot be deleted because it lacks some key fields: @string', array(
      '@string' => $string
        ->getString(),
    )));
  }
  return $this;
}