Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion application/clicommands/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Icinga\Module\Reporting\Clicommands;

use Icinga\Application\Hook\PdfexportHook;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport;
use Icinga\Module\Reporting\Cli\Command;
Expand Down Expand Up @@ -70,7 +71,12 @@
$format = strtolower($format);
switch ($format) {
case 'pdf':
$content = Pdfexport::first()->htmlToPdf($report->toPdf());
// TODO: Remove this once the dependency on the Pdfexport module is removed
/** @var PdfexportHook $exporter */
$exporter = method_exists(PdfexportHook::class, 'first')

Check failure on line 76 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Call to function method_exists() with 'Icinga\\Application\\Hook\\PdfexportHook' and 'first' will always evaluate to true.

Check failure on line 76 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Call to function method_exists() with 'Icinga\\Application\\Hook\\PdfexportHook' and 'first' will always evaluate to true.

Check failure on line 76 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Call to function method_exists() with 'Icinga\\Application\\Hook\\PdfexportHook' and 'first' will always evaluate to true.

Check failure on line 76 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Call to function method_exists() with 'Icinga\\Application\\Hook\\PdfexportHook' and 'first' will always evaluate to true.
Comment thread
sukhwinder33445 marked this conversation as resolved.
? PdfexportHook::first()
: Pdfexport::first();
$content = $exporter->htmlToPdf($report->toPdf());

Check failure on line 79 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.3) / PHPStan 8.3

Call to an undefined method Icinga\Application\Hook\PdfexportHook::htmlToPdf().

Check failure on line 79 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.2) / PHPStan 8.2

Call to an undefined method Icinga\Application\Hook\PdfexportHook::htmlToPdf().

Check failure on line 79 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.5) / PHPStan 8.5

Call to an undefined method Icinga\Application\Hook\PdfexportHook::htmlToPdf().

Check failure on line 79 in application/clicommands/DownloadCommand.php

View workflow job for this annotation

GitHub Actions / PHP / Static analysis (8.4) / PHPStan 8.4

Call to an undefined method Icinga\Application\Hook\PdfexportHook::htmlToPdf().
break;
case 'csv':
$content = $report->toCsv();
Expand Down
11 changes: 7 additions & 4 deletions application/controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Icinga\Module\Reporting\Controllers;

use Exception;
use Icinga\Application\Hook;
use Icinga\Application\Hook\PdfexportHook;
use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport;
use Icinga\Module\Reporting\Database;
use Icinga\Module\Reporting\Model;
Expand Down Expand Up @@ -244,9 +244,12 @@ public function downloadAction(): void

switch ($type) {
case 'pdf':
/** @var Hook\PdfexportHook $exports */
$exports = Pdfexport::first();
$exports->streamPdfFromHtml($this->report->toPdf(), $name);
// TODO: Remove this once the dependency on the Pdfexport module is removed
/** @var PdfexportHook $exporter */
$exporter = method_exists(PdfexportHook::class, 'first')
Comment thread
sukhwinder33445 marked this conversation as resolved.
Comment thread
sukhwinder33445 marked this conversation as resolved.
? PdfexportHook::first()
: Pdfexport::first();
$exporter->streamPdfFromHtml($this->report->toPdf(), $name);
exit;
case 'csv':
$response = $this->getResponse();
Expand Down
22 changes: 8 additions & 14 deletions library/Reporting/Actions/SendMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Icinga\Module\Reporting\Actions;

use Icinga\Application\Config;
use Icinga\Application\Logger;
use Icinga\Application\Hook\PdfexportHook;
use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport;
use Icinga\Module\Reporting\Hook\ActionHook;
use Icinga\Module\Reporting\Mail;
Expand All @@ -15,7 +15,6 @@
use ipl\Stdlib\Str;
use ipl\Validator\CallbackValidator;
use ipl\Validator\EmailAddressValidator;
use Throwable;

class SendMail extends ActionHook
{
Expand Down Expand Up @@ -49,19 +48,14 @@ public function execute(Report $report, array $config)

switch ($config['type']) {
case 'pdf':
/** @var Pdfexport $exporter */
$exporter = Pdfexport::first();
$exporter->asyncHtmlToPdf($report->toPdf())->then(
function ($pdf) use ($mail, $name, $recipients) {
$mail->attachPdf($pdf, $name);
$mail->send(null, $recipients);
}
)->catch(function (Throwable $e) {
Logger::error($e);
Logger::debug($e->getTraceAsString());
});
// TODO: Remove this once the dependency on the Pdfexport module is removed
/** @var PdfexportHook $exporter */
$exporter = method_exists(PdfexportHook::class, 'first')
Comment thread
sukhwinder33445 marked this conversation as resolved.
? PdfexportHook::first()
: Pdfexport::first();
$mail->attachPdf($exporter->htmlToPdf($report->toPdf()), $name);

return;
break;
case 'csv':
$mail->attachCsv($report->toCsv(), $name);

Expand Down
Loading