function LinearHistory::delete

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

Overrides CheckpointListInterface::delete

File

core/lib/Drupal/Core/Config/Checkpoint/LinearHistory.php, line 118

Class

LinearHistory
A chronological list of Checkpoint objects.

Namespace

Drupal\Core\Config\Checkpoint

Code

public function delete(string $id) : static {
    if (!isset($this->checkpoints[$id])) {
        throw new UnknownCheckpointException(sprintf('Cannot delete a checkpoint with the ID "%s" as it does not exist', $id));
    }
    foreach ($this->checkpoints as $key => $checkpoint) {
        unset($this->checkpoints[$key]);
        if ($checkpoint->id === $id) {
            break;
        }
    }
    $this->state
        ->set(self::CHECKPOINT_KEY, $this->checkpoints);
    return $this;
}

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