You are here

public function InMemoryStorage::deleteAll in Configuration Provider 8

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

src/InMemoryStorage.php, line 139

Class

InMemoryStorage
Provides an in memory confituration storage.

Namespace

Drupal\config_provider

Code

public function deleteAll($prefix = '') {
  if ($prefix === '') {
    $this->config[$this->collection] = [];
  }
  else {
    foreach (array_keys($this->config[$this->collection]) as $name) {
      if (strpos($name, $prefix) === 0) {
        unset($this->config[$this->collection][$name]);
      }
    }
  }
  return TRUE;
}