StringDatabaseStorage::delete

public StringDatabaseStorage::delete($string)

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 187

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;
}
doc_Drupal
2016-10-29 09:45:07
Comments
Leave a Comment

Please login to continue.