Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[FrameworkBundle][Serializer] Allow setting$objectClassResolver
via configuration#60092
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
$objectClassResolver
via configuration$objectClassResolver
via configurationf737ffb
tob20009c
Compareif (!($enableMaxDepth = $context[self::ENABLE_MAX_DEPTH] ?? $this->defaultContext[self::ENABLE_MAX_DEPTH] ?? false) | ||
if (!($context[self::ENABLE_MAX_DEPTH] ?? $this->defaultContext[self::ENABLE_MAX_DEPTH] ?? false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
IIUC, this means everybody using the Serializer with Doctrine entities will need this, isn't it?
Shouldn't we patch DoctrineBundle instead so that there's nothing to configure on the user side?
Currently, the
MaxDepth
feature doesn't work correctly with Doctrine proxies because theisMaxDepthReached
method relies on the object's class:symfony/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
Lines 1053 to 1075 in091ae5b
This class is determined using
get_class()
, which returns a different result for proxy and non-proxy objects:symfony/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
Line 149 in091ae5b
Both the
ObjectNormalizer
andPropertyNormalizer
have a$objectClassResolver
property, but there is currently no way to configure it.This PR introduces a new configuration option to set the
$objectClassResolver
. You can provide either a callable or a service:Using a callable:
Using a service: