$object->newfield = 'newval'. * A $object->newfield in a get context will fail, too. Each model has to implement the static method fieldInfo(). * The returned value should be a array with the property names of the class as keys and the value type description as value. * * The type description has to contain the type at least, but can contain addition options, separated by commas. * allowed types are: * * BASE * * * EXTENDED * * * Adding an [] after the type defines a list of values. * * Additional options: * * * @package MCMS\Modeling * @author Stefan Daurer * @since 1.0.0.0 */ abstract class Model extends \Mammut\StrictObject implements iModel { private $initalized = false; // universal getter method for all properties which start with [a-z] public function __call($name, $arguments) { if(preg_match('/get([A-Z][a-zA-Z0-9_]*)/', $name, $match)) { $pname = strtolower(substr($match[1], 0, 1)) . substr($match[1], 1); if(isset($this->$pname)) return $this->$pname; else throw new \InvalidArgumentException("no such method '{$name}' in " . __CLASS__); } else throw new \InvalidArgumentException("no such method '{$name}' in " . __CLASS__); } /** * this method should be called to mark this object as initialized */ public function initalize() { $this->initalized = true; } public function isInitalized() { return (boolean) $this->initalized; } public static function fieldInfo() { return array(); } public static function fieldDBMapping() { $result = array(); // should now work, as we support only php >= 5.3 foreach(static::fieldInfo() as $field=>$info) $result[$field] = $field; // simple 1:1 mapping by default return $result; } }