public function StringDatabaseStorage::delete

Implements Drupal\locale\StringStorageInterface::delete().

Overrides StringStorageInterface::delete

File

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

Class

StringDatabaseStorage
Defines the locale string class.

Namespace

Drupal\locale

Code

public function delete($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;
}