function MemoryStorage::deleteAll

Same name in this branch
  1. 11.x core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php \Drupal\Core\KeyValueStore\MemoryStorage::deleteAll()
Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Config/MemoryStorage.php \Drupal\Core\Config\MemoryStorage::deleteAll()
  2. 9 core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php \Drupal\Core\KeyValueStore\MemoryStorage::deleteAll()
  3. 8.9.x core/lib/Drupal/Core/Config/MemoryStorage.php \Drupal\Core\Config\MemoryStorage::deleteAll()
  4. 8.9.x core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php \Drupal\Core\KeyValueStore\MemoryStorage::deleteAll()
  5. 10 core/lib/Drupal/Core/Config/MemoryStorage.php \Drupal\Core\Config\MemoryStorage::deleteAll()
  6. 10 core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php \Drupal\Core\KeyValueStore\MemoryStorage::deleteAll()

Overrides StorageInterface::deleteAll

File

core/lib/Drupal/Core/Config/MemoryStorage.php, line 131

Class

MemoryStorage
Provides an in memory configuration storage.

Namespace

Drupal\Core\Config

Code

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 (str_starts_with($name, $prefix)) {
            $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;
}

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