2016-03-08 42 views
2

我有我想有两个Hatoas链接和自定义序列化的实体客户symfony的HATEOAS和JMS系列化

/** 
* Customer ORM Entity 
* 
* @package AppBundle\Entity 
* 
* @Hateoas\Relation("self", href = @Hateoas\Route("get_customers", parameters = { "customer" = "expr(object.getId())" })) 
* @Hateoas\Relation("customers", href = @Hateoas\Route("cget_customers")))) 
*/ 

这是对HATEOAS的注释链接

AppBundle\Entity\Customer: 
    exclusion_policy: ALL 
    virtual_properties: 
     getFullName: 
      serialized_name: full_name 
      type: string 

这是我的YAML配置为jms序列化,但由于某种原因它也删除了讨厌的链接。

我怎样才能找回来?告诉序列化程序不要删除_links属性?

回答

3

Hateoas documentation它说:

重要:你必须配置串行和HATEOAS以同样的方式。例如。如果您使用YAML配置串行器,请使用YAML配置Hateoas。

例如,使用YAML format进行配置,应解决问题。

2

作为@appit说,你应该使用与序列化器相同的配置。为了您的例子试试这个:

AppBundle\Entity\Customer: 
    exclusion_policy: ALL 
    virtual_properties: 
     getFullName: 
      serialized_name: full_name 
      type: string 
    relations: 
     - 
     href: 
      route: get_customers 
      parameters: 
       customer: expr(object.getId()) 
    #  absolute: 0 
     customers: 
      route: cget_customers 

希望这有助于