Hi Manel,
The strategy suggested by Marco Pivetta is the one I've adopted (a long
time ago). It fits well specially when you have to assemble an hierarchy of
entities (associations).
Taking Marco's example, suppose you had another entity called
UserPreferences and an association between this entity and \My\User entity.
You could implement the toJSON method in both classes and you would have
something like the following:
class My\User {
protected $username;
protected $password;
protected $otherStuff;
/**
@var \My\UserPreferences
... @ORM association configs ...
**/
protected $userPreferences;
public function toJSON() {
return array(
"username" => $this->username,
"otherStuff" => $this->otherStuff,
"userPreferences" => $this->getUserPreferences()->toJSON()
);
}
/*setters and getters*/
}
Hope this help you.
Diogo
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.