function StringDatabaseStorage::delete

Same name and namespace in other branches
  1. 9 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::delete()
  2. 8.9.x core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::delete()
  3. 10 core/modules/locale/src/StringDatabaseStorage.php \Drupal\locale\StringDatabaseStorage::delete()

File

core/modules/locale/src/StringDatabaseStorage.php, line 188

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.