Search code examples
symfonyserializationhateoasjmsserializerbundle

symfony hateoas and jms serialization


I have an entity Customer that i want to have both Hatoas Links and custom serialization

/**
 * 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"))))
 */

That is the annotation for the hateoas links

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

That is my yaml configuration for the jms serialization but for some reason it also remove the hateoas links.

How can i get it back? Tell to the serializer to not remove the _links property?


Solution

  • In Hateoas documentation it says:

    Important: you must configure both the Serializer and Hateoas the same way. E.g. if you use YAML for configuring Serializer, use YAML for configuring Hateoas.

    For example, use the YAML format for configuration and your issue should be solved.