You are here

public function StorageReplaceDataWrapper::deleteAll in Drupal 9

Same name and namespace in other branches
  1. 8 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 (strpos($name, $prefix) === 0) {
        unset($this->replacementData[$this->collection][$name]);
      }
    }
  }
  return $this->storage
    ->deleteAll($prefix);
}