Configurable PDF exports (#5641)

This commit is contained in:
Kevin Papst
2025-09-23 18:32:31 +02:00
committed by GitHub
parent 5d3e46cce2
commit 6d78c6ba36
107 changed files with 2428 additions and 1575 deletions

View File

@@ -26,25 +26,41 @@ use App\Repository\Query\ProjectQuery;
use App\Repository\Query\TimesheetQuery;
use App\Twig\SecurityPolicy\ExportPolicy;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\DependencyInjection\Attribute\Exclude;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;
use Twig\Extension\SandboxExtension;
/**
* TODO 3.0 remove default values from constructor parameters and make class final
* @final
*/
#[Exclude]
class HtmlRenderer implements ExportRendererInterface
{
use RendererTrait;
private string $id = 'html';
private string $template = 'default.html.twig';
public function __construct(
protected readonly Environment $twig,
protected readonly EventDispatcherInterface $dispatcher,
private readonly ProjectStatisticService $projectStatisticService,
private readonly ActivityStatisticService $activityStatisticService
private readonly ActivityStatisticService $activityStatisticService,
private string $id = 'html', // deprecated default parameter - TODO 3.0
private readonly string $title = 'print', // deprecated default parameter - TODO 3.0
private string $template = 'export/print.html.twig', // deprecated default parameter - TODO 3.0
) {
}
public function isInternal(): bool
{
return false;
}
public function getType(): string
{
return 'html';
}
/**
* @return MetaTableTypeInterface[]
*/
@@ -109,14 +125,20 @@ class HtmlRenderer implements ExportRendererInterface
protected function getTemplate(): string
{
return '@export/' . $this->template;
return $this->template;
}
/**
* @deprecated since 2.40.0
*/
public function setTemplate(string $filename): void
{
$this->template = $filename;
$this->template = '@export/' . $filename;
}
/**
* @deprecated since 2.40.0
*/
public function setId(string $id): void
{
$this->id = $id;
@@ -129,6 +151,6 @@ class HtmlRenderer implements ExportRendererInterface
public function getTitle(): string
{
return 'print';
return $this->title;
}
}