function MemoryStorage::deleteAll

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

File

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

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

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