Skip to content

Commit 6eb862b

Browse files
committed
Added use statements
1 parent d041dca commit 6eb862b

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

book/controller.rst

+4
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ that's responsible for generating the HTML (or other format) for the controller.
498498
The ``renderView()`` method renders a template and returns its content. The
499499
content from the template can be used to create a ``Response`` object::
500500

501+
use Symfony\Component\HttpFoundation\Response;
502+
501503
$content = $this->renderView('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name));
502504

503505
return new Response($content);
@@ -692,6 +694,8 @@ The only requirement for a controller is to return a ``Response`` object. The
692694
abstraction around the HTTP response - the text-based message filled with HTTP
693695
headers and content that's sent back to the client::
694696

697+
use Symfony\Component\HttpFoundation\Response;
698+
695699
// create a simple Response with a 200 status code (the default)
696700
$response = new Response('Hello '.$name, 200);
697701

book/forms.rst

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ user must be bound to the form. Add the following functionality to your
203203
controller::
204204

205205
// ...
206+
use Symfony\Component\HttpFoundation\Request;
206207

207208
public function newAction(Request $request)
208209
{

book/http_cache.rst

+6
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ its creation more manageable:
307307

308308
.. code-block:: php
309309
310+
use Symfony\Component\HttpFoundation\Response;
311+
310312
$response = new Response();
311313
312314
// mark the response as either public or private
@@ -643,6 +645,8 @@ Put another way, the less you do in your application to return a 304 response,
643645
the better. The ``Response::isNotModified()`` method does exactly that by
644646
exposing a simple and efficient pattern::
645647

648+
use Symfony\Component\HttpFoundation\Response;
649+
646650
public function showAction($articleSlug)
647651
{
648652
// Get the minimum information to compute
@@ -1013,6 +1017,8 @@ Here is how you can configure the Symfony2 reverse proxy to support the
10131017
// app/AppCache.php
10141018

10151019
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
1020+
use Symfony\Component\HttpFoundation\Request;
1021+
use Symfony\Component\HttpFoundation\Response;
10161022

10171023
class AppCache extends HttpCache
10181024
{

book/http_fundamentals.rst

+4
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ on that value. This can get ugly quickly:
368368
.. code-block:: php
369369
370370
// index.php
371+
use Symfony\Component\HttpFoundation\Request;
372+
use Symfony\Component\HttpFoundation\Response;
371373
$request = Request::createFromGlobals();
372374
$path = $request->getPathInfo(); // the URI path being requested
373375
@@ -441,6 +443,8 @@ specific PHP method ``contactAction`` inside a class called ``MainController``:
441443

442444
.. code-block:: php
443445
446+
use Symfony\Component\HttpFoundation\Response;
447+
444448
class MainController
445449
{
446450
public function contactAction()

book/templating.rst

+2
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ you're actually using the templating engine service. For example::
929929

930930
is equivalent to:
931931

932+
use Symfony\Component\HttpFoundation\Response;
933+
932934
$engine = $this->container->get('templating');
933935
$content = $engine->render('AcmeArticleBundle:Article:index.html.twig');
934936

book/translation.rst

+10-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ for example, that we're translating a simple message from inside a controller:
9696

9797
.. code-block:: php
9898
99+
// ...
100+
use Symfony\Component\HttpFoundation\Response;
101+
99102
public function indexAction()
100103
{
101104
$t = $this->get('translator')->trans('Symfony2 is great');
@@ -171,6 +174,9 @@ Sometimes, a message containing a variable needs to be translated:
171174

172175
.. code-block:: php
173176
177+
// ...
178+
use Symfony\Component\HttpFoundation\Response;
179+
174180
public function indexAction($name)
175181
{
176182
$t = $this->get('translator')->trans('Hello '.$name);
@@ -186,11 +192,14 @@ variable with a "placeholder":
186192

187193
.. code-block:: php
188194
195+
// ...
196+
use Symfony\Component\HttpFoundation\Response;
197+
189198
public function indexAction($name)
190199
{
191200
$t = $this->get('translator')->trans('Hello %name%', array('%name%' => $name));
192201
193-
new Response($t);
202+
return new Response($t);
194203
}
195204
196205
Symfony2 will now look for a translation of the raw message (``Hello %name%``)

0 commit comments

Comments
 (0)