From 3f8c53e82ab77fa396106ee31b3604e28a6b8f61 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 19 Jan 2023 21:34:54 +0100 Subject: [PATCH] [Controller] Mention the use of the Clock component in `DateTimeValueResolver` --- controller/value_resolver.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/controller/value_resolver.rst b/controller/value_resolver.rst index 6ceeee77084..578b2738d56 100644 --- a/controller/value_resolver.rst +++ b/controller/value_resolver.rst @@ -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 `, + 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 ` 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``.