You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #41414 Support statusCode default param when loading template 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 getti
8000
ng 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.
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ CHANGELOG
17
17
* Add `configureContainer()`, `configureRoutes()`, `getConfigDir()` and `getBundlesPath()` to `MicroKernelTrait`
18
18
* Add support for configuring log level, and status code by exception class
19
19
* Bind the `default_context` parameter onto serializer's encoders and normalizers
20
+
* Add support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller
0 commit comments