function CheckpointStorage::listAll

Overrides StorageInterface::listAll

File

core/lib/Drupal/Core/Config/Checkpoint/CheckpointStorage.php, line 171

Class

CheckpointStorage
Provides a config storage that can make checkpoints.

Namespace

Drupal\Core\Config\Checkpoint

Code

public function listAll($prefix = '') {
    if (count($this->checkpoints) === 0) {
        throw new NoCheckpointsException();
    }
    $names = $new_configuration = [];
    foreach ($this->getCheckpointsToReadFrom() as $checkpoint) {
        $checkpoint_names = array_keys(array_filter($this->getKeyValue($checkpoint->id, $this->collection)
            ->getAll(), function (mixed $value, string $name) use (&$new_configuration, $prefix) {
            if ($name === static::CONFIG_COLLECTION_KEY) {
                return FALSE;
            }
            // Remove any that don't start with the prefix.
            if ($prefix !== '' && !str_starts_with($name, $prefix)) {
                return FALSE;
            }
            // We've determined in a previous checkpoint that the configuration did
            // not exist.
            if (in_array($name, $new_configuration, TRUE)) {
                return FALSE;
            }
            // If the value is FALSE then the configuration was created after the
            // checkpoint.
            if ($value === FALSE) {
                $new_configuration[] = $name;
                return FALSE;
            }
            return TRUE;
        }, ARRAY_FILTER_USE_BOTH));
        $names = array_merge($names, $checkpoint_names);
    }
    // Remove any names that did not exist prior to the checkpoint.
    $active_names = array_diff($this->activeStorage
        ->listAll($prefix), $new_configuration);
    $names = array_unique(array_merge($names, $active_names));
    sort($names);
    return $names;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.