@@ -27,9 +27,6 @@ abstract class Record extends DataObject
27
27
28
28
protected static bool $ deleteChildren = true ;
29
29
30
- /** @var array<string,array<callable>> */
31
- protected static array $ displayTransforms = [];
32
-
33
30
protected bool $ empty = true ;
34
31
35
32
/** @var array<string,array<mixed>> */
@@ -40,9 +37,6 @@ abstract class Record extends DataObject
40
37
/** @var array<string> */
41
38
protected static array $ primaryKeys = [];
42
39
43
- /** @var array<string,array<callable>> */
44
- protected static array $ setTransforms = [];
45
-
46
40
protected static string $ table = '' ;
47
41
48
42
protected string $ validator = '' ;
@@ -129,24 +123,7 @@ public function __get(string $field) : mixed
129
123
return $ relationshipObject ->getValue ($ relationship );
130
124
}
131
125
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 );
150
127
}
151
128
152
129
/**
@@ -201,12 +178,6 @@ public function __set(string $field, mixed $value) : void
201
178
}
202
179
203
180
$ this ->validateFieldExists ($ field );
204
-
205
- if (isset (static ::$ setTransforms [$ field ]))
206
- {
207
- $ value = static ::$ setTransforms [$ field ]($ value );
208
- }
209
-
210
181
$ expectedType = static ::$ fields [$ field ][self ::PHP_TYPE_INDEX ];
211
182
$ haveType = \get_debug_type ($ value );
212
183
@@ -243,24 +214,6 @@ public function __set(string $field, mixed $value) : void
243
214
$ this ->current [$ field ] = $ value ;
244
215
}
245
216
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
-
264
217
public function blankDate (?string $ date ) : string
265
218
{
266
219
if ('1000-01-01 ' > $ date )
@@ -322,24 +275,6 @@ public function delete() : bool
322
275
return \PHPFUI \ORM ::execute ($ sql , $ input );
323
276
}
324
277
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
-
343
278
/**
344
279
* @return bool true if empty (default values)
345
280
*/
@@ -612,11 +547,6 @@ public function setFrom(array $values, bool $loaded = false) : static
612
547
if (isset (static ::$ fields [$ field ]))
613
548
{
614
549
$ this ->empty = false ;
615
-
616
- if (isset (static ::$ setTransforms [$ field ]))
617
- {
618
- $ value = static ::$ setTransforms [$ field ]($ value );
619
- }
620
550
$ this ->current [$ field ] = $ value ;
621
551
}
622
552
}
0 commit comments