function LinearHistory::delete

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Config/Checkpoint/LinearHistory.php \Drupal\Core\Config\Checkpoint\LinearHistory::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.