API reference / Quittio \ Core \ View
ViewNode
class in quittio/core · implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
Quittio\Core\View\ViewNode · Source
Read-only node of the invoice view model with recorded property access.
Templates use object syntax ($invoice->seller->name). Every read of a leaf value that is
not null (scalar or formatted value) is recorded in the access log, so that the mandatory
field guard can tell which values a custom template printed. A value counts as printed
when it is read as a leaf: also in a condition such as if ($invoice->buyer->vatId) and
while a loop reads the items of a list. Counting a list (count(), isEmpty(), isset()) and
reading null values are not recorded: count($invoice->legalNotes) prints no note.
Nested nodes are typed: $invoice->seller is a Model\PartyView, $invoice->lines a Model\ViewList of Model\LineView. The typed nodes are ViewNodes whose keys are documented as typed properties, so they read, loop, count and record exactly like this class.
Properties#
| Property | Type | Description |
|---|---|---|
$data protected | array<string|int, mixed> | |
$log protected | AccessLog | |
$path protected | string |
Methods#
| Method | Description |
|---|---|
->__construct() | |
->__get() | |
->__isset() | |
->count() | Number of entries of this node, e.g. lines of a list. Not recorded as read. |
->getIterator() | Items are read (and recorded) one by one while the template loops over them. |
->isEmpty() | Whether this node has no entries. Not recorded as read. |
->jsonSerialize() | Encodes the plain values like toArray(), which counts as reading every value below this node. |
->offsetExists() | Whether $offset holds a value other than null, e.g. isset($node['vatId']). Not recorded as read. |
->offsetGet() | Reads $offset like property access, e.g. $node['name']: a nested node for a list or group, otherwise the value, which is recorded as read unless it is null. |
->offsetSet() | Always throws LogicException: the view model is read-only. |
->offsetUnset() | Always throws LogicException: the view model is read-only. |
->read() | |
->toArray() | Plain values, e.g. for implode(); counts as reading every value below this node. |
__construct()#
public function __construct(
array<string|int, mixed> $data,
AccessLog $log,
string $path = '',
)| Parameter | Type | Description |
|---|---|---|
$data | array<string|int, mixed> | |
$log | AccessLog | |
$path | string = '' |
__get()#
public function __get(string $name): mixed| Parameter | Type | Description |
|---|---|---|
$name | string |
- Returns
mixed
__isset()#
public function __isset(string $name): bool| Parameter | Type | Description |
|---|---|---|
$name | string |
- Returns
bool
count()#
public function count(): intNumber of entries of this node, e.g. lines of a list. Not recorded as read.
- Returns
int
getIterator()#
public function getIterator(): TraversableItems are read (and recorded) one by one while the template loops over them.
- Returns
Traversable
isEmpty()#
public function isEmpty(): boolWhether this node has no entries. Not recorded as read.
- Returns
bool
jsonSerialize()#
public function jsonSerialize(): mixedEncodes the plain values like toArray(), which counts as reading every value below this node.
- Returns
mixed
offsetExists()#
public function offsetExists(mixed $offset): boolWhether $offset holds a value other than null, e.g. isset($node['vatId']). Not recorded as read.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
- Returns
bool
offsetGet()#
public function offsetGet(mixed $offset): mixedReads $offset like property access, e.g. $node['name']: a nested node for a list or group, otherwise the value, which is recorded as read unless it is null.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
- Returns
mixed
offsetSet()#
public function offsetSet(mixed $offset, mixed $value): voidAlways throws LogicException: the view model is read-only.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed | |
$value | mixed |
offsetUnset()#
public function offsetUnset(mixed $offset): voidAlways throws LogicException: the view model is read-only.
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
read()#
protected function read(string|int $key): mixed| Parameter | Type | Description |
|---|---|---|
$key | string|int |
- Returns
mixed
toArray()#
public function toArray(): array<string|int, mixed>Plain values, e.g. for implode(); counts as reading every value below this node.
- Returns
array<string|int, mixed>