-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalizer should define the attributes to normalize #113
Comments
in general, i think things would be clearer if we change the behaviour to explicitly define attributes that should be normalized. right now, it feels kind of magic if you dont know that the symfony serializer is used 🙂 but we should definitely avoid that the user needs to implement a |
A way for implementing this without the need of a The |
After thinking about this once again, I concluded that it would probably be a cleaner solution to not use the interface NormalizerInterface
{
- /**
- * @return string[]
- */
- public function getIgnoredAttributes(object $object): array;
-
- /**
- * @param mixed[] $normalizedData
- *
- * @return mixed[]
- */
- public function enhance(object $object, array $normalizedData): array;
-
+ /**
+ * @return mixed[]
+ */
+ public function normalize(object $object): array;
} In additional, we can think about adding a With this solution, the I see the following advantages of such a solution:
|
👍 for a new interface. But removing not sure about removing the serialization and the serializer make it simple to add a additional field to the normalized object. |
Currently the NormalizeEnhancer only define which getters should not be called for normalization. Maybe the other way around would be better instead of defining what should be excluded it should be defined what should be included like we normally do it in sulu when using jms exlude all strategy.
There are currently 2 way to define which attributes could be serialized.
The first one is by using the Normalizer Attributes parameter
[AbstractNormalizer::ATTRIBUTES => ['template', 'templateData', ...]
.The second one is using Serialization Groups introducing a
Content
serialization group would have the advantage that the developer could just use annotations and don't need to write a custom NormalizeEnhancer for just adding new property to the normalized data.The text was updated successfully, but these errors were encountered: