@@ -27,9 +27,6 @@ abstract class Record extends DataObject
2727
2828 protected static bool $ deleteChildren = true ;
2929
30- /** @var array<string,array<callable>> */
31- protected static array $ displayTransforms = [];
32-
3330 protected bool $ empty = true ;
3431
3532 /** @var array<string,array<mixed>> */
@@ -40,9 +37,6 @@ abstract class Record extends DataObject
4037 /** @var array<string> */
4138 protected static array $ primaryKeys = [];
4239
43- /** @var array<string,array<callable>> */
44- protected static array $ setTransforms = [];
45-
4640 protected static string $ table = '' ;
4741
4842 protected string $ validator = '' ;
@@ -129,24 +123,7 @@ public function __get(string $field) : mixed
129123 return $ relationshipObject ->getValue ($ relationship );
130124 }
131125
132- if (isset (static ::$ fields [$ field ]))
133- {
134- return $ this ->displayTransform ($ field );
135- }
136-
137- $ id = $ field . \PHPFUI \ORM ::$ idSuffix ;
138-
139- if (\array_key_exists ($ id , $ this ->current ))
140- {
141- $ type = '\\' . \PHPFUI \ORM ::$ recordNamespace . '\\' . \PHPFUI \ORM ::getBaseClassName ($ field );
142-
143- if (\class_exists ($ type ))
144- {
145- return new $ type ($ this ->current [$ id ]);
146- }
147- }
148-
149- throw new \PHPFUI \ORM \Exception (static ::class . ":: {$ field } is not a valid field " );
126+ return parent ::__get ($ field );
150127 }
151128
152129 /**
@@ -201,12 +178,6 @@ public function __set(string $field, mixed $value) : void
201178 }
202179
203180 $ this ->validateFieldExists ($ field );
204-
205- if (isset (static ::$ setTransforms [$ field ]))
206- {
207- $ value = static ::$ setTransforms [$ field ]($ value );
208- }
209-
210181 $ expectedType = static ::$ fields [$ field ][self ::PHP_TYPE_INDEX ];
211182 $ haveType = \get_debug_type ($ value );
212183
@@ -243,24 +214,6 @@ public function __set(string $field, mixed $value) : void
243214 $ this ->current [$ field ] = $ value ;
244215 }
245216
246- /**
247- * Add a transform for get. Callback is passed value.
248- */
249- public static function addDisplayTransform (string $ field , callable $ callback ) : void
250- {
251- static ::$ displayTransforms [$ field ] = $ callback ;
252- }
253-
254- /**
255- * Add a transform for set. Callback is passed value.
256- */
257- public function addSetTransform (string $ field , callable $ callback ) : static
258- {
259- static ::$ setTransforms [$ field ] = $ callback ;
260-
261- return $ this ;
262- }
263-
264217 public function blankDate (?string $ date ) : string
265218 {
266219 if ('1000-01-01 ' > $ date )
@@ -322,24 +275,6 @@ public function delete() : bool
322275 return \PHPFUI \ORM ::execute ($ sql , $ input );
323276 }
324277
325- /**
326- * Transform a field for display
327- */
328- public function displayTransform (string $ field , mixed $ value = null ) : mixed
329- {
330- if (null === $ value )
331- {
332- $ value = $ this ->current [$ field ] ?? null ;
333- }
334-
335- if (! isset (static ::$ displayTransforms [$ field ]))
336- {
337- return $ value ;
338- }
339-
340- return static ::$ displayTransforms [$ field ]($ value );
341- }
342-
343278 /**
344279 * @return bool true if empty (default values)
345280 */
@@ -612,11 +547,6 @@ public function setFrom(array $values, bool $loaded = false) : static
612547 if (isset (static ::$ fields [$ field ]))
613548 {
614549 $ this ->empty = false ;
615-
616- if (isset (static ::$ setTransforms [$ field ]))
617- {
618- $ value = static ::$ setTransforms [$ field ]($ value );
619- }
620550 $ this ->current [$ field ] = $ value ;
621551 }
622552 }
0 commit comments