Extract common features from normalizer to be able to decorate them easily
See original GitHub issueCurrently JSON and JSON-LD are handled by two different normalizers, both of them extending ApiPlatform\Core\Serializer\AbstractItemNormalizer
.
I wanted to add/modify properties on one of my resources (eg. setting URLs for images managed by LiipImagineBundle) and could not find a way to do it without decorating both api_platform.serializer.normalizer.item
and api_platform.jsonld.normalizer.item
:
app.normalizer.image:
class: AppBundle\Serializer\ImageNormalizer
decorates: 'api_platform.serializer.normalizer.item'
arguments:
- '@app.normalizer.image.inner'
(...)
app.normalizer.jsonld.image:
class: AppBundle\Serializer\ImageNormalizer
decorates: 'api_platform.jsonld.normalizer.item'
arguments:
- '@app.normalizer.jsonld.image.inner'
(...)
Wouldn’t it make sense to have a common item normalizer injected in every other item normalizers and be able to only decorate that one?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:9 (6 by maintainers)
Top Results From Across the Web
All about Feature Scaling - Towards Data Science
The most common techniques of feature scaling are Normalization and Standardization. Normalization is used when we want to bound our values ...
Read more >8 Feature Engineering Techniques for Machine Learning
Understand what is feature engineering and why is it important for machine learning and explore a list of top feature engineering techniques ...
Read more >Feature Extraction Techniques - NLP - GeeksforGeeks
This article focuses on basic feature extraction techniques in NLP to analyse the similarities between pieces of text.
Read more >How and why do normalization and feature scaling work?
It's simply a case of getting all your data on the same scale: if the scales for different features are wildly different, this...
Read more >Speech Recognition — Feature Extraction MFCC & PLP
It is easier to develop models and to train these models with independent features. One popular audio feature extraction method is the Mel-frequency ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@soyuka Wouldn’t it be possible to keep the normalizers separated but still having a “base” normalizer used by all of them ?
There is already a big part of the code that is shared between them (
ApiPlatform\Core\Serializer\AbstractItemNormalizer
) so at first I was expecting something like:api_platform.serializer.normalizer.item
: do the common things, basically what AbstractItemNormalizer does nowadaysapi_platform.json.normalizer.item
: usesapi_platform.serializer.normalizer.item
(the same way it callsparent::denormalize
at the end of its own denormalize method) and does specific thingsapi_platform.jsonld.normalizer.item
: same thing but with jsonld specific partsapi_platform.hal.normalizer.item
: same thing but with hal specific partsThat would still allow people to only decorate json/jsonld/hal normalizers if needed, or decorate the common normalizer for properties that must be added/modified in every formats.
If we can find a way of refactoring to extract out common functionality, I say go ahead. 😄