Added jobs, controllers, and PDF generation logic for management report runtime as defined in Spec 379. Includes artifact migrations, payload builders, and testing coverage. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #450
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\ReviewPacks;
|
|
|
|
final class ManagementReportPdfRuntimeGate
|
|
{
|
|
/**
|
|
* @return array{
|
|
* enabled: bool,
|
|
* driver: string,
|
|
* runtime_validated: bool,
|
|
* is_blocked: bool,
|
|
* reason_code: ?string,
|
|
* reason: ?string
|
|
* }
|
|
*/
|
|
public function decision(): array
|
|
{
|
|
$enabled = (bool) config('tenantpilot.pdf_renderer.enabled', false);
|
|
$driver = trim((string) config('tenantpilot.pdf_renderer.driver', 'gotenberg'));
|
|
$runtimeValidated = (bool) config('tenantpilot.pdf_renderer.runtime_validated', false);
|
|
|
|
if (! $enabled) {
|
|
return $this->blocked($enabled, $driver, $runtimeValidated, 'renderer_disabled', 'PDF rendering is disabled for this environment.');
|
|
}
|
|
|
|
if ($driver !== 'gotenberg') {
|
|
return $this->blocked($enabled, $driver, $runtimeValidated, 'renderer_driver_unsupported', 'The configured PDF renderer driver is not supported.');
|
|
}
|
|
|
|
if (! $runtimeValidated) {
|
|
return $this->blocked($enabled, $driver, $runtimeValidated, 'runtime_validation_missing', 'Management PDF generation is blocked until the Gotenberg runtime is validated on Staging.');
|
|
}
|
|
|
|
return [
|
|
'enabled' => $enabled,
|
|
'driver' => $driver,
|
|
'runtime_validated' => $runtimeValidated,
|
|
'is_blocked' => false,
|
|
'reason_code' => null,
|
|
'reason' => null,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array{
|
|
* enabled: bool,
|
|
* driver: string,
|
|
* runtime_validated: bool,
|
|
* is_blocked: bool,
|
|
* reason_code: string,
|
|
* reason: string
|
|
* }
|
|
*/
|
|
private function blocked(bool $enabled, string $driver, bool $runtimeValidated, string $reasonCode, string $reason): array
|
|
{
|
|
return [
|
|
'enabled' => $enabled,
|
|
'driver' => $driver,
|
|
'runtime_validated' => $runtimeValidated,
|
|
'is_blocked' => true,
|
|
'reason_code' => $reasonCode,
|
|
'reason' => $reason,
|
|
];
|
|
}
|
|
}
|