You are here

public function MemoryStorage::listAll in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Config/MemoryStorage.php \Drupal\Core\Config\MemoryStorage::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/lib/Drupal/Core/Config/MemoryStorage.php, line 113

Class

MemoryStorage
Provides an in memory configuration storage.

Namespace

Drupal\Core\Config

Code

public function listAll($prefix = '') {
  if (empty($this->config[$this->collection])) {

    // If the collection is empty no keys are set.
    return [];
  }
  $names = array_keys($this->config[$this->collection]);
  if ($prefix !== '') {
    $names = array_filter($names, function ($name) use ($prefix) {
      return strpos($name, $prefix) === 0;
    });
  }
  return $names;
}