Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Serializer default groups #32622

Closed
Closed
@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