Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Add new normalizer: PropertyInfoNormalizer based on PropertyInfo / PropertyAccess components #30960

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

Closed

Conversation

joelwurtz
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes (not done yet)
Tests pass? no
Fixed tickets #30818
License MIT
Doc PR -

This add the new Normalizer, as a Draft as we don't have all the building blocks actually, to show how we want to resolve things.

Will update this PR on the course of others advancement for #30818

@joelwurtz joelwurtz changed the title Add basic implementation for the PropertyInfoNormalizer [Serializer] Add basic implementation for the PropertyInfoNormalizer Apr 7, 2019
@joelwurtz joelwurtz changed the title [Serializer] Add basic implementation for the PropertyInfoNormalizer [Serializer] Add new normalizer: PropertyInfoNormalizer based on PropertyInfo / PropertyAccess components Apr 7, 2019
Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very promising!


private $objectClassResolver;

public function __construct($instantiator, ObjectPropertyListExtractor $normalizerExtractor, PropertyListExtractorInterface $denormalizerExtractor, PropertyAccessorInterface $propertyAccessor, AdvancedNameConverterInterface $nameConverter = null, callable $objectClassReolver = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should allow to pass the standard NameConverterInterface here (and pass the extra argument required for the advanced one).

public function normalize($object, $format = null, array $context = [])
{
$properties = $this->normalizerExtractor->getProperties($object, $context);
$class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t we deal with Doctrine proxies here?

Copy link
Contributor Author

@joelwurtz joelwurtz Apr 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what we do isn't it ?

Allowing an object class resolver will allow to inject a specific callback to handle this problem.

@Nyholm
Copy link
Member

Nyholm commented Jun 21, 2020

What is the status of this PR?

@joelwurtz could you finish this or leave a comment to help others taking over this PR?

@joelwurtz
Copy link
Contributor Author

This PR need the advancement of all points present in #30818 as it will use all interface / implementations make on those differents PR to create this new normalizer

$propertyName = $this->nameConverter ? $this->nameConverter->normalize($property, $class, $format, $context) : $property;
$value = $this->propertyAccessor->getValue($object, $property);

if (!is_scalar($value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add null !== $value && before to save some iterations, wdyt?

@fabpot fabpot closed this Oct 7, 2020
@fabpot
Copy link
Member

fabpot commented Oct 7, 2020

We've just moved away from master as the main branch to use 5.x instead. Unfortunately, I cannot reopen the PR and change the target branch to 5.x. Can you open a new PR referencing this one to not loose the discussion? Thank you for your understanding and for your help.

@joelwurtz joelwurtz deleted the feature/propery-info-normalizer branch August 14, 2023 20:13
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.

7 participants