Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] add UidNormalizer#36406
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
3e2abfb to74235abCompare5ff8932 toabe7069Compare| * Made`BrowserKitAssertionsTrait` report the original error message in case of a failure | ||
| * Added ability for`config:dump-reference` and`debug:config` to dump and debug kernel container extension configuration. | ||
| * Deprecated`session.attribute_bag` service and`session.flash_bag` service. | ||
| * Added`UidNormalizer` to the framework serializer. |
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.
Can be removed
| <serviceid="serializer.normalizer.uid"class="Symfony\Component\Serializer\Normalizer\UidNormalizer"> | ||
| <!-- Run before serializer.normalizer.object--> | ||
| <tagname="serializer.normalizer"priority="-880" /> | ||
| </service> |
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.
Should be moved to the new PHP config file.
For the priority, I would use -915 to be consistent with the other very specialized normalizers.
| * added support for`\stdClass` to`ObjectNormalizer` | ||
| * added the ability to ignore properties using metadata (e.g.`@Symfony\Component\Serializer\Annotation\Ignore`) | ||
| * added an option to serialize constraint violations payloads (e.g. severity) | ||
| * added`UidNormalizer` |
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.
Should be moved to the 5.2.0 section.
| */ | ||
| publicfunctionnormalize($object,string$format =null,array$context = []) | ||
| { | ||
| if (!$objectinstanceof AbstractUid) { |
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.
The condition can be removed as the supports method garuantees that already.
| /** | ||
| * {@inheritdoc} | ||
| * | ||
| * @throws InvalidArgumentException |
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.
Can be removed
| /** | ||
| * {@inheritdoc} | ||
| * | ||
| * @throws NotNormalizableValueException |
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.
Can be removed
| */ | ||
| publicfunctiondenormalize($data,string$type,string$format =null,array$context = []) | ||
| { | ||
| if (!class_exists(AbstractUid::class)) { |
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.
Can be removed
| try { | ||
| $uid = Ulid::class ===$type ? Ulid::fromString($data) : Uuid::fromString($data); | ||
| }catch (\InvalidArgumentException$exception) { | ||
| thrownewNotNormalizableValueException('The data is not a valid'.$type.' string representation.'); |
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.
You should use sprintf here.
fabpot commentedSep 1, 2020
@guillbdx Can you have a look at the feedback? |
fabpot commentedSep 10, 2020
Anyone willing to take over this PR? |
fabpot commentedSep 11, 2020
Closing in favor of#38151 |
This PR was merged into the 5.2-dev branch.Discussion----------[Serializer] add UidNormalizer| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets |#36102| License | MIT| Doc PR | symfony/symfony-docs#... <!-- required for new features -->UUID and ULID normalizer.Continuation of#36406Commits-------d6a8993 Update based on feedback1c21c78 UidNormalizer.
UUID and ULID normalizer.