Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Ignore \Traversable in default normalizers. #14540

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

Merged
merged 1 commit into from
May 5, 2015

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented May 4, 2015

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

Before the merge of #13500, default normalizers where never called for \Traversable objects. This PR restore the previous behavior in a cleaner way.
This is also convenient when dealing with Doctrine's ArrayCollection and serialization groups (see #14495).

ping @symfony/deciders

@fabpot
Copy link
Member

fabpot commented May 5, 2015

Thank you @dunglas.

@fabpot fabpot merged commit c9bff46 into symfony:2.7 May 5, 2015
fabpot added a commit that referenced this pull request May 5, 2015
…dunglas)

This PR was merged into the 2.7 branch.

Discussion
----------

[Serializer] Ignore \Traversable in default normalizers.

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

Before the merge of #13500, default normalizers where never called for `\Traversable` objects. This PR restore the previous behavior in a cleaner way.
This is also convenient when dealing with Doctrine's ArrayCollection and serialization groups (see #14495).

ping @symfony/deciders

Commits
-------

c9bff46 [Serializer] Ignore \Traversable in default normalizers. Close #14495.
@sroze
Copy link
Contributor

sroze commented May 13, 2015

By the way, do not serialising \Traversable objects forces us to create a custom normalizer for every domain object that is a collection...

As it'd be a really convenient feature, what do you think about adding an optional \Traversable normalizer that would be enabled only explicitly like that ?

framework:
    serializer:
        normalizers: 
            traversable: true

Well, that can be a way of doing for all normalizers by the way.

/cc @dunglas & @fabpot

@dunglas
Copy link
Member Author

dunglas commented May 13, 2015

The flag can be passed to the constructor of normalizers an the supports method can use it.

@sroze
Copy link
Contributor

sroze commented May 13, 2015

I would prefer a dedicated normalizer that just delegates normalization of each item to other normalizers (though the chained one) instead of putting more conditions in existing normalizers.

@dunglas
Copy link
Member Author

dunglas commented May 14, 2015

I agree. What about the reverse side of #14343 ?

@sroze
Copy link
Contributor

sroze commented May 14, 2015

Yeah, it'd be nice. Maybe this PR should also supports deserialization of any \Traversable but introducing an interface that defines a static constructor, which that a given traversable would implement.

I've some other ideas like the ability to define an accessor for given attributes, so... is the serializer features are frozen because of 2.7 beta or is it still open ?

@dunglas
Copy link
Member Author

dunglas commented May 14, 2015

It's frozen for 2.7 but open for 2.8 and 3.0.

@fabpot
Copy link
Member

fabpot commented May 14, 2015

To be more precise, it's frozen for 2.7, open for 2.8, closed for 3.0. All new features must happen in 2.8, not 3.0.

@dunglas dunglas deleted the fix_14495 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.

3 participants