Skip to content

[FrameworkBundle] Serializer groups support #13107

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 5 commits into from

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Dec 25, 2014

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT
Doc PR not yet

This PR enables serializer groups in the full stack framework (including XML, YAML, annotations and caching).

@dunglas dunglas force-pushed the framework_serializer_groups branch 3 times, most recently from 9de8a0f to 47012cf Compare December 25, 2014 03:53
@dunglas dunglas changed the title [FrameworkBundle] Serializer groups support [WIP] [FrameworkBundle] Serializer groups support Dec 25, 2014
@dunglas dunglas force-pushed the framework_serializer_groups branch 3 times, most recently from 475e6ce to 4ecb81e Compare December 25, 2014 10:23
@dunglas dunglas changed the title [WIP] [FrameworkBundle] Serializer groups support [FrameworkBundle] Serializer groups support Dec 25, 2014
@dunglas
Copy link
Member Author

dunglas commented Dec 25, 2014

This PR is now ready to be reviewed.

@@ -19,6 +19,7 @@
* FrameworkExtension configuration structure.
*
* @author Jeremy Mikola <jmikola@gmail.com>
* @author Kévin Dunglas <dunglas@gmail.com>
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO 4 lines do not qualify for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I'll remove it.

@dunglas
Copy link
Member Author

dunglas commented Mar 3, 2015

Made ObjectNormalizer the default normalizer. #13257 must be merged before this one.

@dunglas
Copy link
Member Author

dunglas commented Mar 3, 2015

ping @symfony/deciders

$reflection = new \ReflectionClass($bundle);
$dirname = dirname($reflection->getFilename());

if (is_file($file = $dirname.'/Resources/config/serialization.xml')) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we have other examples in Symfony where such a "convention" is harcoded? I know it's not the case for the routing, but probably done the same way for the translator.

Copy link
Contributor

Choose a reason for hiding this comment

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

JMSSerializerBundle which is probably the most used use the serializer directory name for configs (see conf) , but it can be changed for any bundle manually. I think we should look for resource existence before searching for a default one.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying that we should make it configurable. As a matter of fact, I think there is no need to make it configurable, I just wanted to be sure that we behave like other parts of the framework.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

The point is to have a coherent behavior for both components (Validation, Translation, Routing...). If we allow to create a file by class (why not, I personally use annotations), it must be the same at least for validation mappings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

For this PR, I'd prefer to keep what we have in other parts of the framework.

Copy link
Member

Choose a reason for hiding this comment

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

The Validator component just got the ability to read the configuration from a directory (see #13855). Why not adapt this approach here too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the pointer @xabbuh. I had not seen this PR.
Support for Resources/config/serialization/*[.xml|.yml] added.

@dunglas dunglas force-pushed the framework_serializer_groups branch from 106fe6f to 290d50b Compare March 10, 2015 10:46
@dunglas
Copy link
Member Author

dunglas commented Mar 10, 2015

Rebased.

if (isset($config['cache']) && $config['cache'] !== 'none') {
$container->setParameter(
'serializer.mapping.cache.prefix',
'serializer_'.hash('sha256', $container->getParameter('kernel.root_dir'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this cause issues if cache is warmed up in one place, and later moved to another directory? I know we not necessarily support such case, but I'd rather avoid adding one more obstacle here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably but this is already the case for the validator: https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L749

If we change this behavior, we must change it everywhere in another PR.

<call method="setNamespace">
<argument>%serializer.mapping.cache.prefix%</argument>
</call>
</service>
Copy link
Member

Choose a reason for hiding this comment

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

For the record, though it still looks a little odd to me to have this service here that may not be used, I do like it. As I mentioned before, it's private, so will be removed if it's not being used. And I think it ends up being quite usable. 👍

@dunglas
Copy link
Member Author

dunglas commented Mar 16, 2015

Is this PR ok to be merged?

@fabpot
Copy link
Member

fabpot commented Mar 18, 2015

Thank you @dunglas.

@fabpot fabpot closed this in 74ec895 Mar 18, 2015
dunglas added a commit to dunglas/symfony that referenced this pull request Mar 18, 2015
dunglas added a commit to dunglas/symfony that referenced this pull request Mar 18, 2015
dunglas added a commit that referenced this pull request Mar 19, 2015
…glas)

This PR was merged into the 2.7 branch.

Discussion
----------

[FrameworkBundle] Fix regression introduced by #13107

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

I've introduced a bug in 83b56f6. An error will be throw if the serializer is enabled but no cache is set.

This is the fix.

Commits
-------

efadac0 [FrameworkBundle] Fix regression introduced by #13107
fabpot added a commit to symfony/symfony-standard that referenced this pull request Apr 15, 2015
This PR was squashed before being merged into the 2.7 branch (closes #764).

Discussion
----------

Serializer groups support

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Enable serializer groups (related to symfony/symfony#13107).

Commits
-------

3561a7c Serializer groups support
@dunglas dunglas deleted the framework_serializer_groups branch December 5, 2015 09:02
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.

9 participants