API reference / Quittio \ Core \ View
MandatoryFieldGuard
final class in quittio/core
Quittio\Core\View\MandatoryFieldGuard · Source
Checks after rendering that the template printed all mandatory values.
A custom template could omit mandatory information (e.g. the VAT identifier); then PDF and XML would differ in content. Access keys are view model paths:
- "[]" stands for every index: "vatRows[].amount" requires the amount of every VAT row;
- "&" combines paths that must all be printed, "|" separates alternatives;
- a path counts only where the view model has a value: paths of null values and empty lists are not required, and a field whose alternatives all have no value is skipped.
Only printed leaf values count (see ViewNode).
Constants#
| Constant | Value | Description |
|---|---|---|
LEGAL_NOTE_SUBJECTS | [\Quittio\Core\Enums\NoteSubjectCode::RegulatoryInformation, \Quittio\Core\Enums\NoteSubjectCode::LegalInformation, \Quittio\Core\Enums\NoteSubjectCode::TaxDecl … | Note subjects (BT-21) that the view model lists in "legalNotes". |
MODE_EXCEPTION | 'exception' | |
MODE_LOG | 'log' | |
MODE_OFF | 'off' |
Methods#
| Method | Description |
|---|---|
->__construct() | |
::address() | The address of a party: all address lines, or street, postcode and city. |
::baseFields() | Fields every invoice PDF must show, independent of the country. |
->check() | |
::notePath() | View model path of the first note that matches, wherever the view model lists it: "legalNotes[i]" for regulatory, legal and tax notes, otherwise "notes[i].content|notes[i].html". |
__construct()#
public function __construct(
string $mode = self::MODE_EXCEPTION,
?LoggerInterface $logger = null,
)| Parameter | Type | Description |
|---|---|---|
$mode | string = self::MODE_EXCEPTION | |
$logger | ?Psr\Log\LoggerInterface = null |
address()#
public static function address(string $party): stringThe address of a party: all address lines, or street, postcode and city.
| Parameter | Type | Description |
|---|---|---|
$party | string |
- Returns
string
baseFields()#
public static function baseFields(InvoiceData $invoice): MandatoryFieldListFields every invoice PDF must show, independent of the country.
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData |
- Returns
MandatoryFieldList
check()#
public function check(MandatoryFieldList $fields, AccessLog $log): list<MandatoryField>| Parameter | Type | Description |
|---|---|---|
$fields | MandatoryFieldList | |
$log | AccessLog |
- Returns
list<MandatoryField>– fields that were not printed
notePath()#
public static function notePath(InvoiceData $invoice, callable $matches): ?stringView model path of the first note that matches, wherever the view model lists it: "legalNotes[i]" for regulatory, legal and tax notes, otherwise "notes[i].content|notes[i].html".
| Parameter | Type | Description |
|---|---|---|
$invoice | InvoiceData | |
$matches | callable |
- Returns
?string