Skip to content

Commit b1da656

Browse files
committed
Merge pull request symfony#560 from hhamon/fix_request_references
Fix request references
2 parents eda47f5 + 2d6bcde commit b1da656

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

book/http_cache.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,9 @@ md5 of the content::
545545

546546
public function indexAction()
547547
{
548-
$response = $this->renderView('MyBundle:Main:index.html.twig');
548+
$response = $this->render('MyBundle:Main:index.html.twig');
549549
$response->setETag(md5($response->getContent()));
550-
$response->isNotModified($this->get('request'));
550+
$response->isNotModified($this->getRequest());
551551

552552
return $response;
553553
}
@@ -598,7 +598,7 @@ header value::
598598
$date = $authorDate > $articleDate ? $authorDate : $articleDate;
599599

600600
$response->setLastModified($date);
601-
$response->isNotModified($this->get('request'));
601+
$response->isNotModified($this->getRequest());
602602

603603
return $response;
604604
}
@@ -643,7 +643,7 @@ exposing a simple and efficient pattern::
643643
$response->setLastModified($article->getPublishedAt());
644644

645645
// Check that the Response is not modified for the given Request
646-
if ($response->isNotModified($this->get('request'))) {
646+
if ($response->isNotModified($this->getRequest())) {
647647
// return the 304 Response immediately
648648
return $response;
649649
} else {
@@ -835,7 +835,7 @@ independent of the rest of the page.
835835
836836
public function indexAction()
837837
{
838-
$response = $this->renderView('MyBundle:MyController:index.html.twig');
838+
$response = $this->render('MyBundle:MyController:index.html.twig');
839839
$response->setSharedMaxAge(600);
840840
841841
return $response;

book/security.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,19 @@ Next, create the controller that will display the login form:
403403
{
404404
public function loginAction()
405405
{
406+
$request = $this->getRequest();
407+
$session = $request->getSession();
408+
406409
// get the login error if there is one
407-
if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
408-
$error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
410+
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
411+
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
409412
} else {
410-
$error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
413+
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
411414
}
412415
413416
return $this->render('AcmeSecurityBundle:Security:login.html.twig', array(
414417
// last username entered by the user
415-
'last_username' => $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
418+
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
416419
'error' => $error,
417420
));
418421
}

book/templating.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ pattern is to do the following:
11551155
11561156
public function indexAction()
11571157
{
1158-
$format = $this->get('request')->getRequestFormat();
1158+
$format = $this->getRequest()->getRequestFormat();
11591159
11601160
return $this->render('AcmeBlogBundle:Blog:index.'.$format.'.twig');
11611161
}

cookbook/form/simple_signup_form_with_mongodb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ the validation and saves the data into MongoDB::
255255

256256
$form = $this->createForm(new RegistrationType(), new Registration());
257257

258-
$form->bindRequest($this->get('request'));
258+
$form->bindRequest($this->getRequest());
259259

260260
if ($form->isValid()) {
261261
$registration = $form->getData();

quick_tour/the_controller.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Getting information from the Request
8888
Besides the values of the routing placeholders, the controller also has access
8989
to the ``Request`` object::
9090

91-
$request = $this->get('request');
91+
$request = $this->getRequest();
9292

9393
$request->isXmlHttpRequest(); // is it an Ajax request?
9494

@@ -118,7 +118,7 @@ by using native PHP sessions.
118118
Storing and retrieving information from the session can be easily achieved
119119
from any controller::
120120

121-
$session = $this->get('request')->getSession();
121+
$session = $this->getRequest()->getSession();
122122

123123
// store an attribute for reuse during a later user request
124124
$session->set('foo', 'bar');

0 commit comments

Comments
 (0)