StorageReplaceDataWrapper::listAll

public StorageReplaceDataWrapper::listAll($prefix = '')

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;
}
doc_Drupal
2016-10-29 09:44:48
Comments
Leave a Comment

Please login to continue.