I have a Phalcon\Mvc\Model
that has various getter properties like getMetadata()
. Some of the values in the database are JSON types, such as the metadata
column. The corresponding properties on the models are strings (JSON strings, specifically). I have getters on the model that convert the JSON strings to arrays via json_decode()
Those work fine in cases where I call them directly.
However, whenever I call the toArray()
method on the model, it returns an array with metadata
as the JSON string instead of the converted associative array, completely ignoring my getter.
Is there a way to make toArray()
use the getters? If not, what would be the recommended way of getting the object as an array, using the getters I've defined on the model? Phalcon uses the setters whenever I set values, so I'm surprised it doesn't naturally use the getters.