Skip to content

Commit

Permalink
Add ProgressChecker::hasProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Nov 18, 2024
1 parent 3ba8021 commit 8302f4d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Glpi/Progress/ProgressChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ public function startProgress(string $key, int $max = 0): void
$this->save($progress);
}

public function hasProgress(string $key): bool
{
return isset($_SESSION['progress'][$key]) && $_SESSION['progress'][$key] instanceof SessionProgress;
}

public function getCurrentProgress(string $key): SessionProgress
{
if (!isset($_SESSION['progress'][$key])) {
if (!$this->hasProgress($key)) {
throw new \RuntimeException(\sprintf(
"Cannot find a progress bar for key \"%s\".",
$key,
Expand Down

0 comments on commit 8302f4d

Please sign in to comment.