Thursday, 3 October 2013

Propel toArray Mechanics in Doctrine?

Propel toArray Mechanics in Doctrine?

I was using Propel for a long time and now I want to try Doctrine. In My
Propel days I used PropelObjectCollection::toArray (for a collection) or
PropelObject::toArray() for a single record to convert the PropelObject
via array to json.
In my company we override the toArray method to store virtual columns in
the array and then the json string. For example:
public function toArray() { $arr = parent::toArray(); $arr['full_name'] =
$this->getFullName(); // full_name isnt part of the table, it's just a
getter return $arr; }
When I turn this into json i have my full_name property in my json and
then in my Extjs store Object (we use extjs).
Now I wanna try doctrine, but doctrine doesn't seem to allow this. Can i
override a function or property in my doctrine class, or can I do this by
annotations, is it possible to generate a json with propertys
('first_name', 'last_name', 'full_name') if my Doctrine class only has the
properties $first_name, $last_name and no $full_name or is there a work
around to achiev the same?
Thanks for your help

No comments:

Post a Comment