Skip to content
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

[Serializer] Mark ObjectNormalizer as final for 7.0 #49953

Merged

Conversation

tucksaun
Copy link
Contributor

@tucksaun tucksaun commented Apr 5, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? yes
Tickets #49291 (review)
License MIT
Doc PR none

Extracted from #49950 and related to #49291 (review)

@tucksaun
Copy link
Contributor Author

tucksaun commented Apr 5, 2023

Friendly ping @dunglas @soyuka as this small change would actually affect ApiPlatform's DocumentNormalizer
Looks to me like ApiPlatform could go with decoration instead?

@soyuka
Copy link
Contributor

soyuka commented Apr 6, 2023

Indeed IMO this is a mistake from us, we should've used the AbstractObjectNormalizer instead. 👍 on making this class final!

@OskarStark OskarStark changed the title [Serializer] Mark ObjectNormalizer as final for 7.0 [Serializer] Mark ObjectNormalizer as final for 7.0 Apr 6, 2023
@fabpot fabpot force-pushed the serializer/final-normalizer-object-normalizer branch from c872c45 to b2828e9 Compare April 8, 2023 16:28
@fabpot
Copy link
Member

fabpot commented Apr 8, 2023

Thank you @tucksaun.

@fabpot fabpot merged commit fd9151d into symfony:6.3 Apr 8, 2023
5 of 9 checks passed
@tucksaun tucksaun deleted the serializer/final-normalizer-object-normalizer branch April 8, 2023 22:10
@ninsuo
Copy link

ninsuo commented Jun 1, 2023

Hello peeps,

Since this class is now final, wouldn't it be possible to put extractAttributes/getAttributeValue/setAttributeValue methods in a trait, to make them reusable?

To give you more context, I've a normalizer that extends ObjectNormalizer and supports classes that implement HasSensitivePropertiesInterface; it first checks for #[NullIfNotGranted(role)] attributes in the object and set unauthorized properties to null, and then calls the parent ObjectNormalizer.

The whole PropertyAcces logic is quite useful and it seems that there are no built-in replacements for them, what's your insights?

Thank you!

Cheers,


Okey, the solution is to inject it instead of extending it.
Injecting the ObjectNormalizer into my normalizer, and calling it instead does the job.
I've the head in the handlebars and can't see such easy solutions 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants