Skip to content

Serializer default groups #32622

@kingschnulli

Description

@kingschnulli

Let's say I have an entity Book:

/**
 * @ApiResource()
 */
class Book
{
    /**
     * @Groups({"read", "write"})
     */
    public $name;

    /**
     * @Groups("write")
     */
    public $author;

    /**
     * This property has no groups
     */
    public $foo;

    // ...
}

What I'm trying to achieve now is to serialize the $foo property, regardless of the current context groups. Is there some way to configure some kind of "default group" for properties where no group was given?

I know I could just add the group to my property, but I was hoping to configure something (or decorate something) so the serializer will return the property $foo.

TLDR: How can I define a default group for all properties? Is this already possible or might be a new feature?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy