public function MemoryStorage::deleteAll in Drupal 10
Same name in this branch
- 10 core/lib/Drupal/Core/Config/MemoryStorage.php \Drupal\Core\Config\MemoryStorage::deleteAll()
- 10 core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php \Drupal\Core\KeyValueStore\MemoryStorage::deleteAll()
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Config/MemoryStorage.php \Drupal\Core\Config\MemoryStorage::deleteAll()
- 9 core/lib/Drupal/Core/Config/MemoryStorage.php \Drupal\Core\Config\MemoryStorage::deleteAll()
Deletes configuration objects whose names start with a given prefix.
Given the following configuration object names:
- node.type.article
- node.type.page
Passing the prefix 'node.type.' will delete the above configuration objects.
Parameters
string $prefix: (optional) The prefix to search for. If omitted, all configuration objects that exist will be deleted.
Return value
bool TRUE on success, FALSE otherwise.
Overrides StorageInterface::deleteAll
File
- core/
lib/ Drupal/ Core/ Config/ MemoryStorage.php, line 130
Class
- MemoryStorage
- Provides an in memory configuration storage.
Namespace
Drupal\Core\ConfigCode
public function deleteAll($prefix = '') {
if (!$this->config
->offsetExists($this->collection)) {
// There's nothing to delete.
return FALSE;
}
if ($prefix === '') {
$this->config
->offsetUnset($this->collection);
return TRUE;
}
$success = FALSE;
foreach (array_keys($this->config[$this->collection]) as $name) {
if (strpos($name, $prefix) === 0) {
$success = TRUE;
unset($this->config[$this->collection][$name]);
}
}
// Remove the collection if it is empty.
if (empty($this->config[$this->collection])) {
$this->config
->offsetUnset($this->collection);
}
return $success;
}