Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature #18834 [Serializer] Add the possibility to filter attributes …
…(dunglas) This PR was merged into the 3.3-dev branch. Discussion ---------- [Serializer] Add the possibility to filter attributes | Q | A | | --- | --- | | Branch? | master | | Bug fix? | no | | New feature? | yes | | BC breaks? | no | | Deprecations? | no | | Tests pass? | yes | | Fixed tickets | n/a | | License | MIT | | Doc PR | todo | This new features give the possibility to the end user to select select fields to normalize. Exemple: ``` php class Foo { public $a = '1'; public $b = '2'; public $c = '3'; } $normalizer = new \Symfony\Component\Serializer\Normalizer\ObjectNormalizer(); $normalizer->normalize(new Foo(), null, ['attributes' => ['a', 'c']]); // ['a' => '1', 'c' => '3'] ``` Denormalization is also supported. This feature works for any normalizer using the `Symfony\Component\Serializer\Normalizer\AbstractNormalizer` class. The main use case is to permit to API clients to optimize responses length by dropping unnecessary information like in the following example: ``` http://exemple.com/cars?fields=a,c {'a' => 1, 'c' => 2} ``` Thanks to this PR, support for this feature will be available out of the box in [API Platform](https://api-platform.com). Commits ------- b3826fb [Serializer] Add the possibility to filter attributes
- Loading branch information
Showing
3 changed files
with
123 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters