function CheckpointStorage::getCheckpointsToReadFrom

Same name in other branches
  1. 10 core/lib/Drupal/Core/Config/Checkpoint/CheckpointStorage.php \Drupal\Core\Config\Checkpoint\CheckpointStorage::getCheckpointsToReadFrom()

Gets the checkpoints to read from.

Return value

\Traversable<string, \Drupal\Core\Config\Checkpoint\Checkpoint> The checkpoints, keyed by ID.

4 calls to CheckpointStorage::getCheckpointsToReadFrom()
CheckpointStorage::exists in core/lib/Drupal/Core/Config/Checkpoint/CheckpointStorage.php
Returns whether a configuration object exists.
CheckpointStorage::getAllCollectionNames in core/lib/Drupal/Core/Config/Checkpoint/CheckpointStorage.php
Gets the existing collections.
CheckpointStorage::listAll in core/lib/Drupal/Core/Config/Checkpoint/CheckpointStorage.php
Gets configuration object names starting with a given prefix.
CheckpointStorage::readMultiple in core/lib/Drupal/Core/Config/Checkpoint/CheckpointStorage.php
Reads configuration data from the storage.

File

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

Class

CheckpointStorage
Provides a config storage that can make checkpoints.

Namespace

Drupal\Core\Config\Checkpoint

Code

private function getCheckpointsToReadFrom() : \Traversable {
    $checkpoint = $this->checkpoints
        ->getActiveCheckpoint();
    
    /** @var \Drupal\Core\Config\Checkpoint\Checkpoint[] $checkpoints_to_read_from */
    $checkpoints_to_read_from = [
        $checkpoint,
    ];
    if ($checkpoint->id !== $this->readFromCheckpoint?->id) {
        // Follow ancestors to find the checkpoint to start reading from.
        foreach ($this->checkpoints
            ->getParents($checkpoint->id) as $checkpoint) {
            array_unshift($checkpoints_to_read_from, $checkpoint);
            if ($checkpoint->id === $this->readFromCheckpoint?->id) {
                break;
            }
        }
    }
    // Replay in parent to child order.
    foreach ($checkpoints_to_read_from as $checkpoint) {
        (yield $checkpoint->id => $checkpoint);
    }
}

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