@@ -94,8 +94,8 @@ a controller object. Controllers are also called *actions*.
94
94
:linenos:
95
95
96
96
// src/Acme/HelloBundle/Controller/HelloController.php
97
-
98
97
namespace Acme\HelloBundle\Controller;
98
+
99
99
use Symfony\Component\HttpFoundation\Response;
100
100
101
101
class HelloController
@@ -208,8 +208,8 @@ passed to that method:
208
208
209
209
<?php
210
210
// src/Acme/HelloBundle/Controller/HelloController.php
211
-
212
211
namespace Acme\HelloBundle\Controller;
212
+
213
213
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
214
214
215
215
class HelloController extends Controller
@@ -276,7 +276,7 @@ the following guidelines in mind while you develop.
276
276
277
277
public function indexAction($last_name, $color, $first_name)
278
278
{
279
- // ..
279
+ // ...
280
280
}
281
281
282
282
* **Each required controller argument must match up with a routing parameter **
@@ -286,15 +286,15 @@ the following guidelines in mind while you develop.
286
286
287
287
public function indexAction($first_name, $last_name, $color, $foo)
288
288
{
289
- // ..
289
+ // ...
290
290
}
291
291
292
292
Making the argument optional, however, is perfectly ok. The following
293
293
example would not throw an exception::
294
294
295
295
public function indexAction($first_name, $last_name, $color, $foo = 'bar')
296
296
{
297
- // ..
297
+ // ...
298
298
}
299
299
300
300
* **Not all routing parameters need to be arguments on your controller **
@@ -304,7 +304,7 @@ the following guidelines in mind while you develop.
304
304
305
305
public function indexAction($first_name, $color)
306
306
{
307
- // ..
307
+ // ...
308
308
}
309
309
310
310
.. tip ::
@@ -349,8 +349,8 @@ Add the ``use`` statement atop the ``Controller`` class and then modify the
349
349
.. code-block :: php
350
350
351
351
// src/Acme/HelloBundle/Controller/HelloController.php
352
-
353
352
namespace Acme\HelloBundle\Controller;
353
+
354
354
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
355
355
use Symfony\Component\HttpFoundation\Response;
356
356
@@ -448,7 +448,7 @@ object that's returned from that controller::
448
448
'color' => 'green'
449
449
));
450
450
451
- // further modify the response or return it directly
451
+ // ... further modify the response or return it directly
452
452
453
453
return $response;
454
454
}
@@ -570,7 +570,7 @@ If you're extending the base controller class, do the following::
570
570
571
571
public function indexAction()
572
572
{
573
- $product = // retrieve the object from database
573
+ $product = ... retrieve the object from database;
574
574
if (!$product) {
575
575
throw $this->createNotFoundException('The product does not exist');
576
576
}
0 commit comments