You are here

public function StorageReplaceDataWrapper::listAll in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config/src/StorageReplaceDataWrapper.php \Drupal\config\StorageReplaceDataWrapper::listAll()

Gets configuration object names starting with a given prefix.

Given the following configuration objects:

  • node.type.article
  • node.type.page

Passing the prefix 'node.type.' will return an array containing the above names.

Parameters

string $prefix: (optional) The prefix to search for. If omitted, all configuration object names that exist are returned.

Return value

array An array containing matching configuration object names.

Overrides StorageInterface::listAll

File

core/modules/config/src/StorageReplaceDataWrapper.php, line 128

Class

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

Namespace

Drupal\config

Code

public function listAll($prefix = '') {
  $names = $this->storage
    ->listAll($prefix);
  $additional_names = [];
  if ($prefix === '') {
    $additional_names = array_keys($this->replacementData[$this->collection]);
  }
  else {
    foreach (array_keys($this->replacementData[$this->collection]) as $name) {
      if (strpos($name, $prefix) === 0) {
        $additional_names[] = $name;
      }
    }
  }
  if (!empty($additional_names)) {
    $names = array_unique(array_merge($names, $additional_names));
  }
  return $names;
}