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#
| Method | Description |
|---|---|
->__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 = [],
)| Parameter | Type | Description |
|---|---|---|
$data | DocumentData | |
$html | string | |
$filenamePattern | string | |
$pdf | ?string = null | |
$notices | list<ValidationMessage> = [] | plausibility hints on the document (DocumentData::notices()) |
contents()#
public function contents(): stringThe main output: the PDF, otherwise the HTML.
- Returns
string
data()#
public function data(): DocumentDataThe calculated document data the output was rendered from.
- Returns
DocumentData
filename()#
public function filename(?string $extension = null): stringFile name of the main output from the configured pattern, with the extension pdf or html; $extension replaces it.
| Parameter | Type | Description |
|---|---|---|
$extension | ?string = null |
- Returns
string
hasPdf()#
public function hasPdf(): boolWhether a PDF was rendered; false for an HTML-only run.
- Returns
bool
html()#
public function html(): stringThe rendered template HTML, also when a PDF was rendered.
- Returns
string
mimeType()#
public function mimeType(): stringMIME 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(): stringThe PDF.
- Returns
string- Throws
LogicException– when the document was rendered as HTML only (see hasPdf())
save()#
public function save(string $path): stringWrites the output to a file, or into a directory (an existing one or a path ending in "/") with filename(); creates missing directories.
| Parameter | Type | Description |
|---|---|---|
$path | string |
- Returns
string– the written path