@@ -177,8 +177,10 @@ file:
177
177
<container xmlns =" http://symfony.com/schema/dic/services"
178
178
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
179
179
xmlns : framework =" http://symfony.com/schema/dic/symfony"
180
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
181
- http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
180
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
181
+ http://symfony.com/schema/dic/services/services-1.0.xsd
182
+ http://symfony.com/schema/dic/symfony
183
+ http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
182
184
183
185
<framework : config >
184
186
<!-- ... -->
@@ -652,7 +654,9 @@ requirements can easily be added for each parameter. For example:
652
654
// ...
653
655
654
656
/**
655
- * @Route("/blog/{page}", defaults={"page": 1}, requirements={"page": "\d+"})
657
+ * @Route("/blog/{page}", defaults={"page": 1}, requirements={
658
+ * "page": "\d+"
659
+ * })
656
660
*/
657
661
public function indexAction($page)
658
662
{
740
744
class MainController extends Controller
741
745
{
742
746
/**
743
- * @Route("/{_locale}", defaults={"_locale": "en"}, requirements={"_locale": "en|fr"})
747
+ * @Route("/{_locale}", defaults={"_locale": "en"}, requirements={
748
+ * "_locale": "en|fr"
749
+ * })
744
750
*/
745
751
public function homepageAction($_locale)
746
752
{
@@ -939,8 +945,12 @@ routing system can be:
939
945
/**
940
946
* @Route(
941
947
* "/articles/{_locale}/{year}/{title}.{_format}",
942
- * defaults: {"_format": "html"}
943
- * requirements: {"_locale": "en|fr", "_format": "html|rss", "year": "\d+"}
948
+ * defaults: {"_format": "html"},
949
+ * requirements: {
950
+ * "_locale": "en|fr",
951
+ * "_format": "html|rss",
952
+ * "year": "\d+"
953
+ * }
944
954
* )
945
955
*/
946
956
public function showAction($_locale, $year, $title)
@@ -1017,7 +1027,7 @@ a slash. URLs matching this route might look like:
1017
1027
This example also highlights the special ``_format `` routing parameter.
1018
1028
When using this parameter, the matched value becomes the "request format"
1019
1029
of the ``Request `` object. Ultimately, the request format is used for such
1020
- things such as setting the ``Content-Type `` of the response (e.g. a ``json ``
1030
+ things as setting the ``Content-Type `` of the response (e.g. a ``json ``
1021
1031
request format translates into a ``Content-Type `` of ``application/json ``).
1022
1032
It can also be used in the controller to render a different template for
1023
1033
each value of ``_format ``. The ``_format `` parameter is a very powerful way
@@ -1109,7 +1119,7 @@ each is made available as an argument to the controller method::
1109
1119
1110
1120
public function showAction($slug)
1111
1121
{
1112
- // ...
1122
+ // ...
1113
1123
}
1114
1124
1115
1125
In reality, the entire ``defaults `` collection is merged with the parameter
@@ -1184,8 +1194,8 @@ configuration:
1184
1194
1185
1195
$collection = new RouteCollection();
1186
1196
$collection->addCollection(
1187
- // second argument is the type, which is required to enable the annotation reader
1188
- // for this resource
1197
+ // second argument is the type, which is required to enable
1198
+ // the annotation reader for this resource
1189
1199
$loader->import("@AppBundle/Controller/", "annotation")
1190
1200
);
1191
1201
@@ -1275,7 +1285,7 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
1275
1285
// app/config/routing.php
1276
1286
use Symfony\Component\Routing\RouteCollection;
1277
1287
1278
- $app = $loader->import('@AppBundle/Controller/');
1288
+ $app = $loader->import('@AppBundle/Controller/', 'annotation' );
1279
1289
$app->addPrefix('/site');
1280
1290
1281
1291
$collection = new RouteCollection();
@@ -1361,7 +1371,9 @@ system. Take the ``blog_show`` example route from earlier::
1361
1371
// '_controller' => 'AppBundle:Blog:show',
1362
1372
// )
1363
1373
1364
- $uri = $this->get('router')->generate('blog_show', array('slug' => 'my-blog-post'));
1374
+ $uri = $this->get('router')->generate('blog_show', array(
1375
+ 'slug' => 'my-blog-post'
1376
+ ));
1365
1377
// /blog/my-blog-post
1366
1378
1367
1379
To generate a URL, you need to specify the name of the route (e.g. ``blog_show ``)
@@ -1429,7 +1441,10 @@ Generating URLs with Query Strings
1429
1441
The ``generate `` method takes an array of wildcard values to generate the URI.
1430
1442
But if you pass extra ones, they will be added to the URI as a query string::
1431
1443
1432
- $this->get('router')->generate('blog', array('page' => 2, 'category' => 'Symfony'));
1444
+ $this->get('router')->generate('blog', array(
1445
+ 'page' => 2,
1446
+ 'category' => 'Symfony'
1447
+ ));
1433
1448
// /blog/2?category=Symfony
1434
1449
1435
1450
Generating URLs from a Template
@@ -1470,7 +1485,7 @@ method::
1470
1485
1471
1486
From a template, in Twig, simply use the ``url() `` function (which generates an absolute URL)
1472
1487
rather than the ``path() `` function (which generates a relative URL). In PHP, pass ``true ``
1473
- to ``generateUrl () ``:
1488
+ to ``generate () ``:
1474
1489
1475
1490
.. configuration-block ::
1476
1491
0 commit comments