Skip to content

Commit 07d1ff4

Browse files
committed
Update first method to actually find the first supported exporter
1 parent 51c5db3 commit 07d1ff4

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

library/Icinga/Application/Hook/PdfexportHook.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
namespace Icinga\Application\Hook;
77

88
use Icinga\Application\Hook;
9+
use Icinga\Application\Logger;
910
use ipl\Html\ValidHtml;
1011
use RuntimeException;
12+
use Throwable;
1113

1214
/**
1315
* Base class for the PDF Export Hook
@@ -24,11 +26,20 @@ public static function first()
2426
if (! Hook::has('Pdfexport')) {
2527
throw new RuntimeException('No PDF exporter available');
2628
}
27-
$pdfexport = Hook::first('Pdfexport');
28-
if (! $pdfexport->isSupported()) {
29-
throw new RuntimeException('PDF exporter is not supported');
29+
30+
foreach (Hook::all('Pdfexport') as $exporter) {
31+
try {
32+
if (! $exporter->isSupported()) {
33+
continue;
34+
}
35+
36+
return $exporter;
37+
} catch (Throwable $e) {
38+
Logger::error('PDF exporter reported an error during support check: %s', $e);
39+
}
3040
}
31-
return $pdfexport;
41+
42+
throw new RuntimeException('Not supported PDF exporter available');
3243
}
3344

3445
/**

0 commit comments

Comments
 (0)