Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] Add PropertyValueNormalizer to AbstractObjectNormalizer for code reusability with composition#46662

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

Open
NorthBlue333 wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromNorthBlue333:feature/allow-extending-abstract-object-normalizer

Conversation

NorthBlue333
Copy link

@NorthBlue333NorthBlue333 commentedJun 13, 2022
edited
Loading

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
TicketsRelates to#46649 (as a note)
LicenseMIT
Doc PR-

As stated in#46649, I would like to enableAbstractObjetNormalizer code resuable to child without having to rewrite all the logic and maintain it. This would also avoid using trick to normalize differently some properties, as it is done by ApiPlatformhere andhere.

I have made comments on my PR to explain some changes.

Please let me know if it needs some changes.

valtzu reacted with thumbs up emoji
@carsonbotcarsonbot added this to the6.2 milestoneJun 13, 2022
@NorthBlue333NorthBlue333 changed the titleChange AbstractObjectNormalizer methods visibility for code reusability[Serializer] Change AbstractObjectNormalizer methods visibility for code reusabilityJun 13, 2022
@@ -441,135 +686,63 @@ abstract protected function setAttributeValue(object $object, string $attribute,
* @throws NotNormalizableValueException
* @throws LogicException
*/
private function validateAndDenormalize(array $types, string $currentClass, string $attribute, mixed $data, ?string $format, array $context): mixed
protected function validateAndDenormalize(array $types, string $currentClass, string $attribute, mixed $data, ?string $format, array $context): mixed
Copy link
Author

@NorthBlue333NorthBlue333Jun 13, 2022
edited
Loading

Choose a reason for hiding this comment

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

This method is made protected because it is used line 392. This allows overriding only the nested properties denormalization logic, and only part of it by using all previous methods provided.

@NorthBlue333NorthBlue333force-pushed thefeature/allow-extending-abstract-object-normalizer branch fromcda47e5 to7bbaab9CompareJune 13, 2022 11:40
*
* This function is not meant to be overriden, only used. If you might want to override validateAndDenormalize.
*/
final protected function isNullDenormalization(Type $type, string $currentClass, string $attribute, mixed $data, ?string $format, array &$context): bool
Copy link
Author

Choose a reason for hiding this comment

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

These functions always receive the same set of arguments in order to stay coherent and help developping. But you might want not to?

@stof
Copy link
Member

Making things protected has a huge impact in term of maintenance, because inheritance-based extension points are the ones for which it is harder to write a BC layer.
Couldn't we provide extension points based on composition instead for that use case ?

ogizanagi, dunglas, fbourigault, and mtarld reacted with thumbs up emoji

@NorthBlue333
Copy link
Author

Sure! Will try to this is as soon as I can.

@dunglas
Copy link
Member

For the record there is an ongoing (yet slow) work to move from inheritance to composition in the Serializer component. So I agree with@stof, it would be better to move this work forward instead of opening more methods.

@NorthBlue333NorthBlue333force-pushed thefeature/allow-extending-abstract-object-normalizer branch 2 times, most recently from12dfe3d to7ff98eaCompareOctober 23, 2022 11:32
@NorthBlue333NorthBlue333 changed the title[Serializer] Change AbstractObjectNormalizer methods visibility for code reusability[Serializer] Add PropertyValueNormalizer to AbstractObjectNormalizer for code reusability with compositionOct 23, 2022
@NorthBlue333
Copy link
Author

NorthBlue333 commentedOct 23, 2022
edited
Loading

Hi there, I have updated my PR according to@stof and@dunglas comments.
I am not so sure about thePropertyValueNormalizer file name, location, and instanciation, I will make any necessary changes to this PR.
Thanks for your time

@NorthBlue333NorthBlue333force-pushed thefeature/allow-extending-abstract-object-normalizer branch 4 times, most recently from23b3904 todf02d70CompareOctober 24, 2022 12:50
@NorthBlue333NorthBlue333force-pushed thefeature/allow-extending-abstract-object-normalizer branch fromdf02d70 to816eddfCompareOctober 24, 2022 15:38
@nicolas-grekasnicolas-grekas modified the milestones:6.2,6.3Nov 5, 2022
@nicolas-grekasnicolas-grekas modified the milestones:6.3,6.4May 23, 2023
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

7 participants
@NorthBlue333@stof@dunglas@fabpot@nicolas-grekas@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp