Element builder: Difference between revisions

From Sunhill Framework Documentation
page created
 
+catchall method
Line 10: Line 10:
* When it is a namespaced class name it is used as such
* When it is a namespaced class name it is used as such
* When it is a string it is used as a property name and looked up via the Properties facade.
* When it is a string it is used as a property name and looked up via the Properties facade.
== Using the property name as a method ==
It's also possible to use the property name as a method. This method accepts excactly one string Parameter and that is the property name.
Example
$builder->integer("int_element");
Creates an element of type integer, names it "int_element" and returns it.


[[Category:Properties]]
[[Category:Properties]]
[[Category:Helpers]]
[[Category:Helpers]]

Revision as of 05:06, 30 September 2024

The ElementBuilder class is a helper for adding elements to a record property.

__construct(RecordProperty $owner)

Takes the owning record property as a parameter for later use.

Adding a property

addProperty(string $property_name, string $name): AbstractProperty

Decides how $property_name is resolved:

  • When it is a namespaced class name it is used as such
  • When it is a string it is used as a property name and looked up via the Properties facade.

Using the property name as a method

It's also possible to use the property name as a method. This method accepts excactly one string Parameter and that is the property name.

Example

$builder->integer("int_element");

Creates an element of type integer, names it "int_element" and returns it.