jms serializer same entity relation

203 Views Asked by At

I have an entity with a manyToOne relation on the same entity

class Post {
    /**
     * @ORM\OneToMany(targetEntity=Post::class, mappedBy="lotParent")
     */
    private $linkedPosts;
}

How can I serialize all my posts properties for the main post without serializing all the properties of the children ?

my yaml serialisation file is like this but all the propoerties are visible for the children :

App\Entity\Post:
    ExclusionPolicy: ALL
    properties:
        id:
            expose: true
            groups: [viewPost, viewChildPost]
        title:
            expose: true
            groups: [viewPost]
        ......
        linkedPosts:
            expose: true
            groups: [viewChildPost]

I don't want the children title in this example. Can I use symfony expressions on serialization groups ? I didn't saw something like this

0

There are 0 best solutions below