@@ -236,7 +236,7 @@ example:
|
236 | 236 |
|
237 | 237 | # app/config/routing.yml
|
238 | 238 | hello:
|
239 |
| -path: /hello/{first_name}/{last_name} |
| 239 | +path: /hello/{firstName}/{lastName} |
240 | 240 | defaults: { _controller: AcmeHelloBundle:Hello:index, color: green }
|
241 | 241 |
|
242 | 242 | .. code-block:: xml
|
@@ -248,7 +248,7 @@ example:
|
248 | 248 | xsi:schemaLocation="http://symfony.com/schema/routing
|
249 | 249 | http://symfony.com/schema/routing/routing-1.0.xsd">
|
250 | 250 |
|
251 |
| -<route id="hello" path="/hello/{first_name}/{last_name}"> |
| 251 | +<route id="hello" path="/hello/{firstName}/{lastName}"> |
252 | 252 | <default key="_controller">AcmeHelloBundle:Hello:index</default>
|
253 | 253 | <default key="color">green</default>
|
254 | 254 | </route>
|
@@ -257,19 +257,19 @@ example:
|
257 | 257 | .. code-block:: php
|
258 | 258 |
|
259 | 259 | // app/config/routing.php
|
260 |
| -$collection->add('hello', new Route('/hello/{first_name}/{last_name}', array( |
| 260 | +$collection->add('hello', new Route('/hello/{firstName}/{lastName}', array( |
261 | 261 | '_controller' => 'AcmeHelloBundle:Hello:index',
|
262 | 262 | 'color' => 'green',
|
263 | 263 | )));
|
264 | 264 |
|
265 | 265 | The controller for this can take several arguments::
|
266 | 266 |
|
267 |
| -public function indexAction($first_name, $last_name, $color) |
| 267 | +public function indexAction($firstName, $lastName, $color) |
268 | 268 | {
|
269 | 269 | // ...
|
270 | 270 | }
|
271 | 271 |
|
272 |
| -Notice that both placeholder variables (``{first_name}``, ``{last_name}``) |
| 272 | +Notice that both placeholder variables (``{firstName}``, ``{lastName}``) |
273 | 273 | as well as the default ``color`` variable are available as arguments in the
|
274 | 274 | controller. When a route is matched, the placeholder variables are merged
|
275 | 275 | with the ``defaults`` to make one array that's available to your controller.
|
@@ -281,11 +281,11 @@ the following guidelines in mind while you develop.
|
281 | 281 |
|
282 | 282 | Symfony is able to match the parameter names from the route to the variable
|
283 | 283 | names in the controller method's signature. In other words, it realizes that
|
284 |
| -the ``{last_name}`` parameter matches up with the ``$last_name`` argument. |
| 284 | +the ``{lastName}`` parameter matches up with the ``$lastName`` argument. |
285 | 285 | The arguments of the controller could be totally reordered and still work
|
286 | 286 | perfectly::
|
287 | 287 |
|
288 |
| -public function indexAction($last_name, $color, $first_name) |
| 288 | +public function indexAction($lastName, $color, $firstName) |
289 | 289 | {
|
290 | 290 | // ...
|
291 | 291 | }
|
@@ -295,25 +295,25 @@ the following guidelines in mind while you develop.
|
295 | 295 | The following would throw a ``RuntimeException`` because there is no ``foo``
|
296 | 296 | parameter defined in the route::
|
297 | 297 |
|
298 |
| -public function indexAction($first_name, $last_name, $color, $foo) |
| 298 | +public function indexAction($firstName, $lastName, $color, $foo) |
299 | 299 | {
|
300 | 300 | // ...
|
301 | 301 | }
|
302 | 302 |
|
303 | 303 | Making the argument optional, however, is perfectly ok. The following
|
304 | 304 | example would not throw an exception::
|
305 | 305 |
|
306 |
| -public function indexAction($first_name, $last_name, $color, $foo = 'bar') |
| 306 | +public function indexAction($firstName, $lastName, $color, $foo = 'bar') |
307 | 307 | {
|
308 | 308 | // ...
|
309 | 309 | }
|
310 | 310 |
|
311 | 311 | * **Not all routing parameters need to be arguments on your controller**
|
312 | 312 |
|
313 |
| -If, for example, the ``last_name`` weren't important for your controller, |
| 313 | +If, for example, the ``lastName`` weren't important for your controller, |
314 | 314 | you could omit it entirely::
|
315 | 315 |
|
316 |
| -public function indexAction($first_name, $color) |
| 316 | +public function indexAction($firstName, $color) |
317 | 317 | {
|
318 | 318 | // ...
|
319 | 319 | }
|
|
0 commit comments