symfony hateoas和jms序列化

symfony hateoas和jms序列化,symfony,serialization,hateoas,jmsserializerbundle,Symfony,Serialization,Hateoas,Jmsserializerbundle,我有一个实体客户,我想同时拥有Hatoas链接和自定义序列化 /** * Customer ORM Entity * * @package AppBundle\Entity * * @Hateoas\Relation("self", href = @Hateoas\Route("get_customers", parameters = { "customer" = "expr(object.getId())" })) * @Hateoas\Relation("customers",

我有一个实体客户,我想同时拥有Hatoas链接和自定义序列化

/**
 * 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
这是我对jms序列化的yaml配置,但出于某种原因,它还删除了hateoas链接

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

中的内容是:

重要提示:必须以相同的方式配置序列化程序和HATEO。例如,如果使用YAML配置序列化程序,请使用YAML配置Hateoas


例如,使用For配置,您的问题应该得到解决。

正如@takeit所说,您应该使用与序列化程序相同的配置。对于您的示例,请尝试以下方法:

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
希望这有帮助