Skip to content

Commit 63d874c

Browse files
committed
Throw exception if pdfexport module is missing
1 parent c9b99bb commit 63d874c

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

application/clicommands/DownloadCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Icinga\Module\Reporting\Clicommands;
77

88
use Icinga\Application\Hook\PdfexportHook;
9+
use Icinga\Application\Modules\Module;
910
use Icinga\Exception\NotFoundError;
1011
use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport;
1112
use Icinga\Module\Reporting\Cli\Command;
@@ -15,6 +16,7 @@
1516
use Icinga\Util\Environment;
1617
use InvalidArgumentException;
1718
use ipl\Stdlib\Filter;
19+
use RuntimeException;
1820

1921
class DownloadCommand extends Command
2022
{
@@ -72,6 +74,10 @@ public function defaultAction()
7274
switch ($format) {
7375
case 'pdf':
7476
// TODO: Remove this once the dependency on the Pdfexport module is removed
77+
if (! Module::exists('pdfexport')) {
78+
throw new RuntimeException('The pdfexport module is not installed');
79+
}
80+
7581
/** @var PdfexportHook $exporter */
7682
$exporter = method_exists(PdfexportHook::class, 'first')
7783
? PdfexportHook::first()

application/controllers/ReportController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Icinga\Module\Reporting\Controllers;
77

88
use Exception;
9-
use Icinga\Application\Hook;
109
use Icinga\Application\Hook\PdfexportHook;
1110
use Icinga\Application\Modules\Module;
1211
use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport;
@@ -26,6 +25,7 @@
2625
use ipl\Web\Widget\ActionBar;
2726
use Icinga\Util\Environment;
2827
use ipl\Web\Widget\ActionLink;
28+
use RuntimeException;
2929

3030
class ReportController extends Controller
3131
{
@@ -248,7 +248,7 @@ public function downloadAction(): void
248248
case 'pdf':
249249
// TODO: Remove this once the dependency on the Pdfexport module is removed
250250
if (! Module::exists('pdfexport')) {
251-
throw new Exception('The pdfexport module is not installed');
251+
throw new RuntimeException('The pdfexport module is not installed');
252252
}
253253

254254
/** @var PdfexportHook $exporter */

library/Reporting/Actions/SendMail.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Icinga\Application\Config;
99
use Icinga\Application\Hook\PdfexportHook;
10+
use Icinga\Application\Modules\Module;
1011
use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport;
1112
use Icinga\Module\Reporting\Hook\ActionHook;
1213
use Icinga\Module\Reporting\Mail;
@@ -15,6 +16,7 @@
1516
use ipl\Stdlib\Str;
1617
use ipl\Validator\CallbackValidator;
1718
use ipl\Validator\EmailAddressValidator;
19+
use RuntimeException;
1820

1921
class SendMail extends ActionHook
2022
{
@@ -49,6 +51,10 @@ public function execute(Report $report, array $config)
4951
switch ($config['type']) {
5052
case 'pdf':
5153
// TODO: Remove this once the dependency on the Pdfexport module is removed
54+
if (! Module::exists('pdfexport')) {
55+
throw new RuntimeException('The pdfexport module is not installed');
56+
}
57+
5258
/** @var PdfexportHook $exporter */
5359
$exporter = method_exists(PdfexportHook::class, 'first')
5460
? PdfexportHook::first()

0 commit comments

Comments
 (0)