-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks #24634
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
[FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks #24634
Conversation
which means we should always favor putting services in xml, then removing them when applicable, instead of adding them in the DI ext? We just did that the wrong way recently in another PR, isn't it? |
Yes indeed, would be better. |
(introduced in symfony/serializer 3.2)
Thank you @ogizanagi. |
…efinitions to xml file & remove unnecessary checks (ogizanagi) This PR was squashed before being merged into the 3.3 branch (closes #24634). Discussion ---------- [FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks | Q | A | ------------- | --- | Branch? | 3.3 <!-- see comment below --> | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A - `DataUriNormalizer` was added in 3.1 (cc7b5af#diff-b7fc65c7d852312152e353f395fc70a8) - `DateTimeNormalizer` was added in 3.1 (6749a70#diff-17828084c07e429d87a1754420d312ef) - `JsonSerializableNormalizer` was added in 3.1 (a678881#diff-537ddf87a3d7ff914be4244a1e0c07f0) - `YamlEncoder` was added in 3.2 (9366a7d#diff-11720cb963c63bb0ad3fb23aba4ae294) `Yaml::DUMP_OBJECT` was added in 3.1 (286103b#diff-519 8000 9351a5995f15f224160f6969931c5R23) - `CsvEncoder` was added in 3.2 (e71f5be#diff-4de6bbbd40ea769ada711de28fb180c8) while on 3.3, FrameworkBundle [conflicts](https://github.com/symfony/symfony/blob/3.3/src/Symfony/Bundle/FrameworkBundle/composer.json#L70) with `"symfony/serializer": "<3.3"` and both 3.1 and 3.2 are EOL anyway. Moving these definitions to the `serializer.xml` file unclutters a bit the `FrameworkExtension`, make things clear about these service being always registered and allows the PhpStorm's Symfony plugin to properly detect and jump to them from classes. Commits ------- 0d7657b [FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks
…r definition to xml (ogizanagi) This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle][Serializer] Move DateIntervalNormalizer definition to xml | Q | A | ------------- | --- | Branch? | 3.4 <!-- see comment below --> | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #24634 (comment) <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Same as #24634 for the remaining normalizer introduced in 3.4. Commits ------- 11244d5 [FrameworkBundle][Serializer] Move DateIntervalNormalizer definition to xml
@@ -86,6 +101,14 @@ | |||
<tag name="serializer.encoder" /> | |||
</service> | |||
|
|||
<service id="serializer.encoder.yaml" class="Symfony\Component\Serializer\Encoder\YamlEncoder"> |
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.
This is broken, symfony/yaml
may not be installed and we now have an error when trying to use the serializer... See https://travis-ci.org/nelmio/NelmioApiDocBundle/jobs/305754242.
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.
Hmm. My bad. I'll look at this soon. Thanks for the report!
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.
Thanks!
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.
See #25179
…n if Yaml component isn't installed (ogizanagi) This PR was merged into the 3.3 branch. Discussion ---------- [FrameworkBundle][Serializer] Remove YamlEncoder definition if Yaml component isn't installed | Q | A | ------------- | --- | Branch? | 3.3 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #24634 (comment) <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Do we need a `"symfony/yaml": "<3.2"` conflict here (the version used in `require-dev`)? Otherwise I'll re-introduce the `!defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')` check instead. Commits ------- a44f8a5 [FrameworkBundle][Serializer] Remove YamlEncoder definition if Yaml component isn't installed
DataUriNormalizer
was added in 3.1 (cc7b5af#diff-b7fc65c7d852312152e353f395fc70a8)DateTimeNormalizer
was added in 3.1 (6749a70#diff-17828084c07e429d87a1754420d312ef)JsonSerializableNormalizer
was added in 3.1 (a678881#diff-537ddf87a3d7ff914be4244a1e0c07f0)YamlEncoder
was added in 3.2 (9366a7d#diff-11720cb963c63bb0ad3fb23aba4ae294)Yaml::DUMP_OBJECT
was added in 3.1 (286103b#diff-5199351a5995f15f224160f6969931c5R23)CsvEncoder
was added in 3.2 (e71f5be#diff-4de6bbbd40ea769ada711de28fb180c8)while on 3.3, FrameworkBundle conflicts with
"symfony/serializer": "<3.3"
and both 3.1 and 3.2 are EOL anyway.Moving these definitions to the
serializer.xml
file unclutters a bit theFrameworkExtension
, make things clear about these service being always registered and allows the PhpStorm's Symfony plugin to properly detect and jump to them from classes.