You are here

public function MongodbConfigStorage::listAll in MongoDB 8

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

src/MongodbConfigStorage.php, line 155
Definition of Drupal\mongodb\Config\MongoStorage.

Class

MongodbConfigStorage

Namespace

Drupal\mongodb

Code

public function listAll($prefix = '') {
  $condition = array();
  if (!empty($prefix)) {
    $condition = array(
      '_id' => new \MongoRegex('/^' . str_replace('.', '\\.', $prefix) . '/'),
    );
  }
  $names = array();
  $result = $this
    ->mongoCollection()
    ->find($condition, array(
    '_id' => TRUE,
  ));
  foreach ($result as $item) {
    $names[] = $item['_id'];
  }
  return $names;
}