Configurable PDF exports (#5641)
This commit is contained in:
@@ -17,17 +17,20 @@ final class PdfContext
|
||||
{
|
||||
private array $options = [];
|
||||
|
||||
public function setOption(string $key, string|array|null|bool $value): void
|
||||
public function setOption(string $key, string|int|array|null|bool $value): void
|
||||
{
|
||||
$this->options[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string|int|array|null|bool>
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function getOption(string $key): array|string|null
|
||||
public function getOption(string $key): string|int|array|null|bool
|
||||
{
|
||||
if (\array_key_exists($key, $this->options)) {
|
||||
return $this->options[$key];
|
||||
|
||||
@@ -25,7 +25,7 @@ trait PdfRendererTrait
|
||||
protected function createPdfResponse(string $content, PdfContext $context): Response
|
||||
{
|
||||
$filename = $context->getOption('filename');
|
||||
if (empty($filename)) {
|
||||
if (!\is_string($filename) || empty($filename)) {
|
||||
throw new \Exception('Empty PDF filename given');
|
||||
}
|
||||
$filename = FileHelper::convertToAsciiFilename($filename);
|
||||
|
||||
Reference in New Issue
Block a user