Skip to content

[Serializer] Docs for the PropertyInfo integration #7042

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 1 commit into from

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Oct 6, 2016

}

$normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor()); //
$serializer = new Serializer(array(new DateTimeNormalizer(), $normalizer));
Copy link

Choose a reason for hiding this comment

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

Missing use statement for DateTimeNormalizer.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@wouterj wouterj added this to the 3.1 milestone Nov 9, 2016
When using the Symfony Standard Edition, all normalizers are automatically configured to use registered extractors.
When using the component standalone, an implementation of :class:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface`,
(usually an instance of :class:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor`) must be passed as the 4th
parameter of the normalizer::
Copy link
Member

Choose a reason for hiding this comment

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

"[...] to the ObjectNormalizer"?

complex types (objects). The type of the class's property will be guessed using the provided
extractor and used to recursively denormalize the inner data.

When using the Symfony Standard Edition, all normalizers are automatically configured to use registered extractors.
Copy link
Member

Choose a reason for hiding this comment

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

[...] to use the registered [...]

-----------------------------------------

The Serializer Component can use the :doc:`PropertyInfo Component </components/property_info>` to denormalize
complex types (objects). The type of the class's property will be guessed using the provided
Copy link
Member

Choose a reason for hiding this comment

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

class'

Copy link
Member Author

Choose a reason for hiding this comment

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

dump($obj->getDate()->format('Y-m-d')); // '1988-01-21'

When a ``PropertyTypeExtractor`` is available, the normalizer will also check that the data to denormalize
matches the type of the property (even for primitive types). For instance, if a ``string`` is provided but
Copy link
Member

Choose a reason for hiding this comment

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

[...] is provided, but [...]


When a ``PropertyTypeExtractor`` is available, the normalizer will also check that the data to denormalize
matches the type of the property (even for primitive types). For instance, if a ``string`` is provided but
the type of the property is ``int``, a :class:`Symfony\\Component\\Serializer\\Exception\\UnexpectedValueException`
Copy link
Member

Choose a reason for hiding this comment

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

an

@dunglas
Copy link
Member Author

dunglas commented Feb 14, 2017

Rebased and fixed.

Status: Needs Review

@xabbuh
Copy link
Member

xabbuh commented Feb 26, 2017

👍 LGTM

Status: Reviewed

@xabbuh
Copy link
Member

xabbuh commented Mar 3, 2017

Thank you @dunglas.

xabbuh added a commit that referenced this pull request Mar 3, 2017
…glas)

This PR was submitted for the 3.1 branch but it was merged into the 3.2 branch instead (closes #7042).

Discussion
----------

[Serializer] Docs for the PropertyInfo integration

Docs for symfony/symfony#17660.

Commits
-------

8e2deb0 [Serializer] Docs for the PropertyInfo integration
@xabbuh xabbuh closed this Mar 3, 2017
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