Skip to content

Update templates.rst for PR symfony/symfony#41414 #15376

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
Dec 2, 2021

Conversation

dayallnash
Copy link
Contributor

Update docs to provide info on potential new feature found here: symfony/symfony#41414

Update docs to provide info on potential new feature found here: symfony/symfony#41414
@dayallnash dayallnash changed the title Update templates.rst Update templates.rst for PR symfony/symfony#41414 May 26, 2021
@javiereguiluz javiereguiluz added the Waiting Code Merge Docs for features pending to be merged label May 26, 2021
@carsonbot carsonbot added this to the next milestone May 26, 2021
fabpot added a commit to symfony/symfony that referenced this pull request Oct 27, 2021
…te directly via route (dayallnash)

This PR was merged into the 5.4 branch.

Discussion
----------

Support `statusCode` default param when loading template directly via route

_This is my first PR to Symfony, so please be patient as I get to grips with the 'admin' process of getting everything exactly how you want it!_

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        | symfony/symfony-docs#15376

### TODO

- [x] submit changes to the documentation and update this PR with a link

### Summary

Added support for `statusCode` default parameter when loading a template directly from route via the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller (like [this](https://symfony.com/doc/current/templates.html#templates-render-from-route)). This will continue to default to a 200 code, but can be changed by updating your route - for instance something like this:

```
test_route:
  path: /test_route
  controller:    Symfony\Bundle\FrameworkBundle\Controller\TemplateController
  defaults:
    # the path of the template to render
    template:  'test.html.twig'
    # the status code to include in the response headers
    statusCode: 201
```
This could be useful for when you want to render a template without adding any extra business logic in a controller, but don't want to return a 200 response.

Commits
-------

5a7b666 Added support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller.
@fabpot fabpot removed the Waiting Code Merge Docs for features pending to be merged label Oct 27, 2021
@javiereguiluz javiereguiluz modified the milestones: next, 5.4 Dec 2, 2021
@javiereguiluz
Copy link
Member

Thanks Dale!

@javiereguiluz javiereguiluz merged commit f852ac9 into symfony:5.4 Dec 2, 2021
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