From 8302f4d550e0165539da056d090fc638cfd995eb Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Fri, 15 Nov 2024 15:21:38 +0100 Subject: [PATCH] Add ProgressChecker::hasProgress --- src/Glpi/Progress/ProgressChecker.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Glpi/Progress/ProgressChecker.php b/src/Glpi/Progress/ProgressChecker.php index 94a4f8cfd8e..cc28dd39972 100644 --- a/src/Glpi/Progress/ProgressChecker.php +++ b/src/Glpi/Progress/ProgressChecker.php @@ -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,