Skip to content

API reference / Quittio \ Core \ Rendering

RenderedDocument

final readonly class in quittio/core

Quittio\Core\Rendering\RenderedDocument · Source

Rendered quote, delivery note, reminder or other document (PDF and HTML, never XML).

Methods#

MethodDescription
->__construct()
->contents()The main output: the PDF, otherwise the HTML.
->data()The calculated document data the output was rendered from.
->filename()File name of the main output from the configured pattern, with the extension pdf or html; $extension replaces it.
->hasPdf()Whether a PDF was rendered; false for an HTML-only run.
->html()The rendered template HTML, also when a PDF was rendered.
->mimeType()MIME type of the main output (contents()): application/pdf, or text/html without a PDF.
->notices()Plausibility hints on the document, in the language of the run, e.g. a reminder that claims reminder fees besides the flat rate (DocumentData::notices()).
->pdf()The PDF.
->save()Writes the output to a file, or into a directory (an existing one or a path ending in "/") with filename(); creates missing directories.

__construct()#

public function __construct(
    DocumentData $data,
    string $html,
    string $filenamePattern,
    ?string $pdf = null,
    list<ValidationMessage> $notices = [],
)
ParameterTypeDescription
$dataDocumentData
$htmlstring
$filenamePatternstring
$pdf?string = null
$noticeslist<ValidationMessage> = []plausibility hints on the document (DocumentData::notices())

contents()#

public function contents(): string

The main output: the PDF, otherwise the HTML.

Returns
string

data()#

public function data(): DocumentData

The calculated document data the output was rendered from.

Returns
DocumentData

filename()#

public function filename(?string $extension = null): string

File name of the main output from the configured pattern, with the extension pdf or html; $extension replaces it.

ParameterTypeDescription
$extension?string = null
Returns
string

hasPdf()#

public function hasPdf(): bool

Whether a PDF was rendered; false for an HTML-only run.

Returns
bool

html()#

public function html(): string

The rendered template HTML, also when a PDF was rendered.

Returns
string

mimeType()#

public function mimeType(): string

MIME type of the main output (contents()): application/pdf, or text/html without a PDF.

Returns
string

notices()#

public function notices(): list<ValidationMessage>

Plausibility hints on the document, in the language of the run, e.g. a reminder that claims reminder fees besides the flat rate (DocumentData::notices()).

Returns
list<ValidationMessage>

pdf()#

public function pdf(): string

The PDF.

Returns
string
Throws
LogicException – when the document was rendered as HTML only (see hasPdf())

save()#

public function save(string $path): string

Writes the output to a file, or into a directory (an existing one or a path ending in "/") with filename(); creates missing directories.

ParameterTypeDescription
$pathstring
Returns
string – the written path

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.