function LinearHistory::add
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Config/Checkpoint/LinearHistory.php \Drupal\Core\Config\Checkpoint\LinearHistory::add()
Adds a new checkpoint.
Parameters
string $id: The ID of the checkpoint add.
string|\Stringable $label: The checkpoint label.
Return value
\Drupal\Core\Config\Checkpoint\Checkpoint The new checkpoint, which is now at the end of the checkpoint sequence.
Overrides CheckpointListInterface::add
File
-
core/
lib/ Drupal/ Core/ Config/ Checkpoint/ LinearHistory.php, line 103
Class
- LinearHistory
- A chronological list of Checkpoint objects.
Namespace
Drupal\Core\Config\CheckpointCode
public function add(string $id, string|\Stringable $label) : Checkpoint {
if (isset($this->checkpoints[$id])) {
throw new CheckpointExistsException(sprintf('Cannot create a checkpoint with the ID "%s" as it already exists', $id));
}
$checkpoint = new Checkpoint($id, $label, $this->time
->getCurrentTime(), $this->activeCheckpoint?->id);
$this->checkpoints[$checkpoint->id] = $checkpoint;
$this->activeCheckpoint = $checkpoint;
$this->state
->set(self::CHECKPOINT_KEY, $this->checkpoints);
return $checkpoint;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.