Skip to content

[FrameworkBundle] Add support for setting headers with TemplateContoller #19911

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
May 23, 2024
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
19 changes: 19 additions & 0 deletions templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,11 @@ provided by Symfony:
site_name: 'ACME'
theme: 'dark'

# optionally you can define HTTP headers to add to the response
headers:
Content-Type: 'text/html'
foo: 'bar'

.. code-block:: xml

<!-- config/routes.xml -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also update xml and php examples ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Foreach new feature, we add directive versionadded to tell is new. You can add it above Checking if a Template Exists title

.. versionadded:: 7.2

    The ``headers`` option was introduced in Symfony 7.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good information 👍

Expand Down Expand Up @@ -734,6 +739,11 @@ provided by Symfony:
<default key="site_name">ACME</default>
<default key="theme">dark</default>
</default>

<!-- optionally you can define HTTP headers to add to the response -->
<default key="headers">
<default key="Content-Type">text/html</default>
</default>
</route>
</routes>

Expand Down Expand Up @@ -764,11 +774,20 @@ provided by Symfony:
'context' => [
'site_name' => 'ACME',
'theme' => 'dark',
],

// optionally you can define HTTP headers to add to the response
'headers' => [
'Content-Type' => 'text/html',
]
])
;
};

.. versionadded:: 7.2

The ``headers`` option was introduced in Symfony 7.2.

Checking if a Template Exists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Loading