Skip to content

[Clock][HttpKernel] [Controller] Mention the use of the Clock component in DateTimeValueResolver #17780

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions controller/value_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,22 @@ Symfony ships with the following value resolvers in the
You can restrict how the input can be formatted with the
:class:`Symfony\\Component\\HttpKernel\\Attribute\\MapDateTime` attribute.

.. tip::

The ``DateTimeInterface`` object is generated with the :doc:`Clock component </components/clock>`,
which means you can have full control over the date and time values the controller receives when
testing your application. This can be achieved by using the
:class:`Symfony\\Component\\Clock\\MockClock` implementation in your test environment.

.. versionadded:: 6.1

The ``DateTimeValueResolver`` was introduced in Symfony 6.1.

.. versionadded:: 6.3

The use of the :doc:`Clock component </components/clock>` to generate the
``DateTimeInterface`` object was introduced in Symfony 6.3.

:class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver\\RequestValueResolver`
Injects the current ``Request`` if type-hinted with ``Request`` or a class
extending ``Request``.
Expand Down