So, I have these models where the PK’s are all binary(16) columns. I’ve had several problems because of them in the Yii framework itself (see links below):
However, I’ve been able to work around these problems. Now, I started using RESTfullYii (v1.15) and I’ve hit a road block again. Problem in occuring where it is trying to convert this model into json string (in protected/extensions/restfullyii/views/api/output.php). CJON::encode() doesn’t like binary strings and it returns the following error:
json_encode() [function.json-encode]: Invalid UTF-8 sequence in argument
In order to work around this problem, I implemented the following rule in my Model:
array('user', 'filter', 'filter'=>'UUIDUtils::bin2hex'),
This doesn’t fix the problem because RESTFullYii is not calling validate() on the model before trying to encode them into JSON. The responsible method is MorrayBehavior::toArray().
I do not see a way to extend MorrayBehavior without modifying some code in RESTFullYii. Also, I’m not sure if my observations (about not calling validate() to trigger rule chain) are correct.
Any help will, as always, be appreciated.