Skip to content

[Serializer] Document Normalizers #10515

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
Oct 23, 2018

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Oct 18, 2018

refs #10505

.. index::
single: Serializer; Custom normalizers

How to Create your Custom Normalizer

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

I copied the schema of https://symfony.com/doc/current/serializer/custom_encoders.html ; So are you sure I should be not consistant with existing documentation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, lets keep it then 👍

private $router;
private $normaliser;

public function __construct(UrlGeneratorInterface $router, ObjectNormalizer $normaliser)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/$normaliser/$normalizer/


namespace AppBundle\Serializer;

use App\Entity\Topic;
Copy link
Contributor

Choose a reason for hiding this comment

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

you use App here, but 2 lines above you are in AppBundle namespace, maybe a mistake?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, good catch :) thanks

@lyrixx lyrixx force-pushed the serializer-normalizer branch from 0837b4f to aa4a747 Compare October 19, 2018 12:06
}
}

Registering it in your app
Copy link
Member

Choose a reason for hiding this comment

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

A question for when we merge this into upper branches. Does Symfony autoconfiguration support Normalizers? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it does ❤️
I already planned to open a new PR to remove theses for new Symfony versions

@javiereguiluz javiereguiluz merged commit aa4a747 into symfony:2.8 Oct 23, 2018
javiereguiluz added a commit that referenced this pull request Oct 23, 2018
This PR was merged into the 2.8 branch.

Discussion
----------

[Serializer] Document Normalizers

refs #10505

Commits
-------

aa4a747 [Serializer] Document Normalizers
@javiereguiluz
Copy link
Member

Thanks Grégoire! This has been merged now.

@lyrixx lyrixx deleted the serializer-normalizer branch October 23, 2018 12:04
@javiereguiluz
Copy link
Member

The change it's now merged in all branches. Next steps would be:

  • A PR to 3.4 to change AppBundle -> App
  • Later: a PR to 4.1 to simplify things and rely on service autoconfiguration.

Thanks!

@lyrixx
Copy link
Member Author

lyrixx commented Oct 24, 2018

I have opened #10543 before reading your last comment.
I have documented in 3.4 the auto-configure part. It was done also for the encoder. Did I miss something ?
(let's continue this discussion if needed in #10543)

Thanks for the merge BTW

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.

4 participants