function LinearHistory::delete
Same name and namespace in other branches
- 10 core/lib/Drupal/Core/Config/Checkpoint/LinearHistory.php \Drupal\Core\Config\Checkpoint\LinearHistory::delete()
Deletes a checkpoint.
Parameters
string $id: The ID of the checkpoint to delete up to: only checkpoints after this one will remain.
Return value
$this
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\CheckpointCode
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;
}
}
$first = reset($this->checkpoints);
if ($first instanceof Checkpoint) {
// Make sure the first checkpoint does not have a parent set.
$fixed = new Checkpoint($first->id, $first->label, $first->timestamp, NULL);
$this->checkpoints[$fixed->id] = $fixed;
}
$this->activeCheckpoint = end($this->checkpoints) ?: NULL;
if (!empty($this->checkpoints)) {
$this->state
->set(self::CHECKPOINT_KEY, $this->checkpoints);
}
else {
$this->state
->delete(self::CHECKPOINT_KEY);
}
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.