Skip to content

[FrameworkBundle] Added caching to TemplateController #6083

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

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,28 @@ class TemplateController extends ContainerAware
* Renders a template.
*
* @param string $template The template name
* @param int|null $maxAge Max age for client caching
* @param int|null $sharedAge Max age for shared (proxy) caching
* @param Boolean|null $private Whether or not caching should apply for client caches only
*
* @return Response A Response instance
*/
public function templateAction($template)
public function templateAction($template, $maxAge = null, $sharedAge = null, $private = null)
{
return $this->container->get('templating')->renderResponse($template);
/** @var $response \Symfony\Component\HttpFoundation\Response */
$response = $this->container->get('templating')->renderResponse($template);
if ($maxAge) {
$response->setMaxAge($maxAge);
}
if ($sharedAge) {
$response->setSharedMaxAge($sharedAge);
}

if ($private) {
$response->setPrivate();
} else if ($private === false || (is_null($private) && ($maxAge || $sharedAge))) {
$response->setPublic($private);
}
return $response;
}
}