From 42b4c95c3ae2d4b0b9153ae4a099dddf292bba1e Mon Sep 17 00:00:00 2001 From: Florian Merle Date: Tue, 26 Nov 2024 13:29:39 +0100 Subject: [PATCH] update controller return value doc --- controller.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/controller.rst b/controller.rst index d4f7f99d43d..40e47dbbedf 100644 --- a/controller.rst +++ b/controller.rst @@ -447,7 +447,7 @@ and provides methods for getting and setting response headers. The header names normalized. As a result, the name ``Content-Type`` is equivalent to the name ``content-type`` or ``content_type``. -In Symfony, a controller is required to return a ``Response`` object:: +In Symfony, a controller usually returns a ``Response`` object:: use Symfony\Component\HttpFoundation\Response; @@ -463,6 +463,14 @@ response types. Some of these are mentioned below. To learn more about the ``Request`` and ``Response`` (and different ``Response`` classes), see the :ref:`HttpFoundation component documentation `. +.. note:: + + When a controller returns a non-``Response`` object, a ``kernel.view`` + listener is expected to transform it into a ``Response`` object; + otherwise an exception is thrown. + + See :ref:`kernel.view event ` for details on the ``kernel.view`` event. + Accessing Configuration Values ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~