Skip to content

[FrameworkBundle] Improve the DX of TemplateController #10320

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
Sep 11, 2018
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
[FrameworkBundle] Improve the DX of TemplateController
  • Loading branch information
dunglas committed Sep 10, 2018
commit fca1a5b75cd59d18630bcc1689da4063de43925c
14 changes: 7 additions & 7 deletions templating/render_without_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Usually, when you need to create a page, you need to create a controller
and render a template from within that controller. But if you're rendering
a simple template that doesn't need any data passed into it, you can avoid
creating the controller entirely, by using the built-in
``Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction``
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\TemplateController`
controller.

For example, suppose you want to render a ``static/privacy.html.twig``
Expand All @@ -22,7 +22,7 @@ can do this without creating a controller:
# config/routes.yaml
acme_privacy:
path: /privacy
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
defaults:
template: static/privacy.html.twig

Expand All @@ -35,7 +35,7 @@ can do this without creating a controller:
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="acme_privacy" path="/privacy">
<default key="_controller">Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction</default>
<default key="_controller">Symfony\Bundle\FrameworkBundle\Controller\TemplateController</default>
<default key="template">static/privacy.html.twig</default>
</route>
</routes>
Expand All @@ -48,7 +48,7 @@ can do this without creating a controller:

$routes = new RouteCollection();
$routes->add('acme_privacy', new Route('/privacy', array(
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction',
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\TemplateController',
'template' => 'static/privacy.html.twig',
)));

Expand Down Expand Up @@ -83,7 +83,7 @@ other variables in your route, you can control exactly how your page is cached:
# config/routes.yaml
acme_privacy:
path: /privacy
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
defaults:
template: 'static/privacy.html.twig'
maxAge: 86400
Expand All @@ -98,7 +98,7 @@ other variables in your route, you can control exactly how your page is cached:
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="acme_privacy" path="/privacy">
<default key="_controller">Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction</default>
<default key="_controller">Symfony\Bundle\FrameworkBundle\Controller\TemplateController</default>
<default key="template">static/privacy.html.twig</default>
<default key="maxAge">86400</default>
<default key="sharedAge">86400</default>
Expand All @@ -113,7 +113,7 @@ other variables in your route, you can control exactly how your page is cached:

$routes = new RouteCollection();
$routes->add('acme_privacy', new Route('/privacy', array(
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction',
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\TemplateController',
'template' => 'static/privacy.html.twig',
'maxAge' => 86400,
'sharedAge' => 86400,
Expand Down