You are here

public function StringDatabaseStorage::delete in Zircon Profile 8

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

Delete string from 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::delete

File

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

Class

StringDatabaseStorage
Defines a class to store localized strings in the database.

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('The string cannot be deleted because it lacks some key fields: ' . $string
      ->getString());
  }
  return $this;
}