Skip to content

Model Helper

Sakya edited this page Nov 26, 2021 · 2 revisions

Itseasy\Model\AbstractModel

This model implement Lamians\Stdlib\ArraySerializableInterface

Any attribute in this model that has populate or getArrayCopy function will be call automatically by the parent

Filter function :

  • set<Attribute> use for filtering value before assigning value to attribute
  • get<Attribute> use for filtering value before returning attribute value

When populate / getArrayCopy function is call from AbstractModel

  1. If filter function exist for given attribute call the filter function
  2. Else if the attribute implements ArraySerializableInterface call attribute populate / getArrayCopy ( nestable )
  3. Else if the attribute has populate / getArrayCopy function call the function ( nestable )
  4. Else assign / return the value directly to / from attribute

Itseasy\Model\RecordModel

This model extend AbstractModel

Predefine attribute:

  • tech_creation_date : database row creation time
  • tech_modification_date : database row modification time
  • tech_timezone : timezone use, default UTC. Remove from getArrayCopy function

Database Requirement:
A database table with tech_creation_date and tech_modification_date column is required.
The column usually is set by BEFORE INSERT trigger and BEFORE UPDATE trigger

Itseasy\Model\CollectionModel

  • This model implement Lamians\Stdlib\ArraySerializableInterface
  • This model does not extend AbstractModel
  • Collection is an ArrayObject
  • Collection has populate function so it will be populate automatically when nested inside AbstractModel
  • Collection use ArrayObject builtin exchangeArray and getArrayCopy function

Clone this wiki locally