8000 [FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks by ogizanagi · Pull Request #24634 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 2 commits into from
Closed

[FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks #24634

wants to merge 2 commits into from

Conversation

ogizanagi
Copy link
Contributor
@ogizanagi ogizanagi commented Oct 19, 2017
Q A
Branch? 3.3
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

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 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.

@nicolas-grekas
Copy link
Member

allows the PhpStorm's Symfony plugin to properly detect and jump to them from classes

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?

@ogizanagi
Copy link
Contributor Author
ogizanagi commented Oct 19, 2017

which means we should always favor putting services in xml, then removing them when applicable, instead of adding them in the DI ext?

Yes indeed, would be better.
For instance in 6185cb1#diff-0e793081ceb720201745c982a568903f, but it was consistent with the way other normalizers were registered so far.
Did you have another PR in mind?

@ogizanagi ogizanagi changed the title [FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file [FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks Oct 19, 2017
@fabpot
Copy link
Member
fabpot commented Oct 19, 2017

Thank you @ogizanagi.

fabpot added a commit that referenced this pull request Oct 19, 2017
…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
@fabpot fabpot closed this Oct 19, 2017
@ogizanagi ogizanagi deleted the minor/3.3/fwb/rm_serializer_conditionals branch October 19, 2017 20:41
fabpot added a commit that referenced this pull request Oct 20, 2017
…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">
Copy link
Contributor

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.

Copy link
Contributor Author

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!

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #25179

fabpot added a commit that referenced this pull request Nov 27, 2017
…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
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.

5 participants
0