Open adallaway opened 9 years ago
Media::encode() casts objects in the view data to arrays. This prevents jsonSerialize() from being called on objects that implement JsonSerializable.
I'm not sure if this is intended behavior but here's a possible fix: https://github.com/UnionOfRAD/lithium/blob/master/net/http/Media.php#L766
if ($data instanceof \JsonSerializable)) { return $data; }
As a workaround, a dummy to() method can be added to the objects:
public function to() { return $this; }
Until we find a clean solution for this, try reregistering the json handler with 'cast' set to false. That only works if you always hand JsonSerializable objects to the view.
json
'cast'
false
Media::encode() casts objects in the view data to arrays. This prevents jsonSerialize() from being called on objects that implement JsonSerializable.
I'm not sure if this is intended behavior but here's a possible fix: https://github.com/UnionOfRAD/lithium/blob/master/net/http/Media.php#L766
As a workaround, a dummy to() method can be added to the objects: