Browse Source

Cache

dev-master
Simon Vieille 2 years ago
parent
commit
b43baac802
No known key found for this signature in database GPG Key ID: 919533E2B946EA10
5 changed files with 23 additions and 15 deletions
  1. +14
    -6
      src/Gist/Controller/Controller.php
  2. +2
    -2
      src/Gist/Controller/EditController.php
  3. +2
    -2
      src/Gist/Controller/LoginController.php
  4. +1
    -1
      src/Gist/Controller/MyController.php
  5. +4
    -4
      src/Gist/Controller/ViewController.php

+ 14
- 6
src/Gist/Controller/Controller.php View File

@ -159,11 +159,10 @@ abstract class Controller
*
* @param string $template
* @param array $params
* @param bool $renderResponse
*
* @return string
*/
public function render($template, array $params = null, $renderResponse = true)
public function render($template, array $params = null)
{
$app = $this->getApp();
@ -175,14 +174,23 @@ abstract class Controller
$params['user'] = $this->getUser();
}
$body = $app['twig']->render(
return $app['twig']->render(
$template,
$params
);
}
if (!$renderResponse) {
return $body;
}
/**
* Creates a Response.
*
* @param string $template
* @param array $params
*
* @return Response
*/
public function createResponse($template, array $params = null)
{
$body = $this->render($template, $params);
$response = new Response($body);


+ 2
- 2
src/Gist/Controller/EditController.php View File

@ -55,7 +55,7 @@ class EditController extends Controller
}
}
return $this->render(
return $this->createResponse(
'Edit/index.html.twig',
array(
'gist' => isset($gist) ? $gist : null,
@ -110,6 +110,6 @@ class EditController extends Controller
$viewOptions['form'] = $form->createView();
return $this->render('Edit/clone.html.twig', $viewOptions);
return $this->createResponse('Edit/clone.html.twig', $viewOptions);
}
}

+ 2
- 2
src/Gist/Controller/LoginController.php View File

@ -57,7 +57,7 @@ class LoginController extends Controller
}
}
return $this->render(
return $this->createResponse(
'Login/register.html.twig',
[
'form' => $form->createView(),
@ -97,7 +97,7 @@ class LoginController extends Controller
$error = $app['translator']->trans('login.login.invalid');
}
return $this->render(
return $this->createResponse(
'Login/login.html.twig',
[
'form' => $form->createView(),


+ 1
- 1
src/Gist/Controller/MyController.php View File

@ -120,7 +120,7 @@ class MyController extends Controller
}
}
return $this->render(
return $this->createResponse(
'My/my.html.twig',
array(
'gists' => $gists,


+ 4
- 4
src/Gist/Controller/ViewController.php View File

@ -31,7 +31,7 @@ class ViewController extends Controller
$viewOptions = $this->getViewOptions($request, $gist, $commit);
if (is_array($viewOptions)) {
return $this->render('View/view.html.twig', $viewOptions);
return $this->createResponse('View/view.html.twig', $viewOptions);
} else {
return $this->notFoundResponse();
}
@ -53,7 +53,7 @@ class ViewController extends Controller
$viewOptions = $this->getViewOptions($request, $gist, $commit);
if (is_array($viewOptions)) {
return $app['twig']->render('View/embed.html.twig', $viewOptions);
return $app['twig']->createResponse('View/embed.html.twig', $viewOptions);
} else {
return $this->notFoundResponse();
}
@ -73,7 +73,7 @@ class ViewController extends Controller
$viewOptions = $this->getViewOptions($request, $gist, $commit);
return new Response(
$this->render('View/embedJs.html.twig', $viewOptions, false),
$this->render('View/embedJs.html.twig', $viewOptions),
200,
array(
'Content-Type' => 'text/javascript',
@ -165,7 +165,7 @@ class ViewController extends Controller
return $this->notFoundResponse();
}
return $this->render(
return $this->createResponse(
'View/revisions.html.twig',
array(
'gist' => $gist,


Loading…
Cancel
Save