Same name and namespace in other branches
  1. 8.9.x core/modules/config/src/StorageReplaceDataWrapper.php \Drupal\config\StorageReplaceDataWrapper::deleteAll()
  2. 9 core/modules/config/src/StorageReplaceDataWrapper.php \Drupal\config\StorageReplaceDataWrapper::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/modules/config/src/StorageReplaceDataWrapper.php, line 150

Class

StorageReplaceDataWrapper
Wraps a configuration storage to allow replacing specific configuration data.

Namespace

Drupal\config

Code

public function deleteAll($prefix = '') {
  if ($prefix === '') {
    $this->replacementData[$this->collection] = [];
  }
  else {
    foreach (array_keys($this->replacementData[$this->collection]) as $name) {
      if (str_starts_with($name, $prefix)) {
        unset($this->replacementData[$this->collection][$name]);
      }
    }
  }
  return $this->storage
    ->deleteAll($prefix);
}