You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue suggests to add support for a passdownGroup option in the normalizer bundle. With this option, the groups passed down to nested objects can be manually defined.
The following PHP class example will demonstrate the use case:
class Bar
{
/** * @Bos\Normalize(group={"api_v3", "id_only"}) * * @var int */public$id;
/** * @Bos\Normalize(group={"api_v3"}, passdownGroup="id_only") * * @var Foo */public$foo;
}
class Foo
{
/** * @Bos\Normalize(group={"api_v3", "id_only"}) * * @var int */public$id;
/** * @Bos\Normalize(group={"api_v3"}) * * @var string */public$name;
}
Calling the normalizer like:
$this->normalizer->normalize($bar, 'api_v3');
Would result in:
{
"id": 1,
"foo": {
"id": 1
}
}
Instead of:
{
"id": 1,
"foo": {
"id": 1,
"name": "test"
}
}
Without this feature, a lot of manual groups might have to be defined to support simple use cases like above.
The text was updated successfully, but these errors were encountered:
Your goal would be to only get the ID of certain type="collection", is that correct?
Could we instead of a passDownGroup use a specific option like normalizeIdOnly?
Or maybe we could add an indicator of the ID field like normalizeIdField=uuid (if the id field is not used, but another field is actually the identifier). We could even make it a class annotation (@Bos\Normalize(idField="uuid")) and use that in combination with normalizeIdOnly
This issue suggests to add support for a
passdownGroup
option in the normalizer bundle. With this option, the groups passed down to nested objects can be manually defined.The following PHP class example will demonstrate the use case:
Calling the normalizer like:
Would result in:
Instead of:
Without this feature, a lot of manual groups might have to be defined to support simple use cases like above.
The text was updated successfully, but these errors were encountered: