Record properties

From Sunhill Framework Documentation

Record properties are properties that consist of other properties (even other record properties). The elements of a record properties are accessed just like a object in php.

Example:

$record_property->integer_property = 5; // calls $integer_property->setValue(5);

Defining member properties

Any record property consist at least of one member property. There are three ways to tell the record what members it has

Defining a initializeRecord() method

For record classes that have their own class its useful to define its own initializeRecord() method. This method is called by the constructor of a record class and initializes the elements.

Passing a callback to the constructor or the setupRecord() method

For simple ad-hoc records it is better to pass a callback closure to the constructor that does the same as initializeRecord. This makes it possible to use the default RecordProperty class rather than defining a new one.

appendElement(string|AbstractProperty $property, string $name, string $inclusion = 'include'): AbstractProperty

While the two methods above work with a mediator class (ElementBuilder) that is able to lookup class names and translate it into namespaced classes, this method does the work of appending an element. It can be called directly, normally it's more comfortable to use the ElementBuilder.

Adding runtime properties called attributes

Exploring members

hasElement(string $name): bool

elementCount(): int

Traversing elements