我有以下关联
return this.httpClient
.put<T>(`${this.url}/${this.endpoint}`, JSON.stringify(item), {
headers: this.addHeaders()
})
.subscribe(data => this.serializer.fromJson(data) as T);
当我选择一个具有某些UserNote的用户时,上面的关联会产生以下objetc:
class User
{
....
/**
* @OneToMany(targetEntity="UserNote", mappedBy="user", fetch="EAGER")
*/
public $userNote;
....
}
class UserNote implements
{
....
/**
* @ManyToOne(targetEntity="User", inversedBy="userNote")
* @JoinColumn(name="id_user", referencedColumnName="id_user")
*/
public $user;
....
}
因此,当我使用json_encode时,我得到以下结果:
App\Models\Entity\User Object
(
[id] => 4
[name] => Filipe Rodrigues
[email] => filipe@email.com.br
[login] => master
[password] => *********
[date] => DateTime Object
(
[date] => 2016-05-04 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[lastLogin] => DateTime Object
(
[date] => 2017-08-09 11:45:38.000000
[timezone_type] => 3
[timezone] => UTC
)
[numLogin] => 161
[fone1] => 1112345678
[fone2] =>
[cep] => 09112000
[adress] => Rua Sila NAlon Gonzzaga
[cpf] => 289.233.498-52
[typeUser] => 3
[facebook] =>
[site] =>
[plan] =>
[idPlan] => 1
[note] =>
[fl_vip] =>
[fl_trial] => 0
[fl_cob] => 0
[recorrenceCode] => 0566AEA4DADA9861147E5F95DD2AF24B
[billingDay] => 13
[status] => 8
[token] =>
[parent] =>
[userNote] => Doctrine\ORM\PersistentCollection Object
(
[snapshot:Doctrine\ORM\PersistentCollection:private] => Array
(
[0] => App\Models\Entity\UserNote Object
(
[id] => 1
[note] => teste
[date] => DateTime Object
(
[date] => 2018-01-02 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[user] => App\Models\Entity\User Object
*RECURSION*
)
)
......
userNote没有转换,如何使用json_encode转换教义关联?
有人可以帮助我吗?