2016-03-08 40 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 

希望這有助於