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.
This issue suggests to add support for a
passdownGroupoption 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:
{ "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.