@@ -173,8 +173,10 @@ file:
173
173
<container xmlns =" http://symfony.com/schema/dic/services"
174
174
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
175
175
xmlns : framework =" http://symfony.com/schema/dic/symfony"
176
- xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
177
- http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
176
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
177
+ http://symfony.com/schema/dic/services/services-1.0.xsd
178
+ http://symfony.com/schema/dic/symfony
179
+ http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
178
180
179
181
<framework : config >
180
182
<!-- ... -->
@@ -649,7 +651,9 @@ be added for each parameter. For example:
649
651
// ...
650
652
651
653
/**
652
- * @Route("/blog/{page}", defaults={"page": 1}, requirements={"page": "\d+"})
654
+ * @Route("/blog/{page}", defaults={"page": 1}, requirements={
655
+ * "page": "\d+"
656
+ * })
653
657
*/
654
658
public function indexAction($page)
655
659
{
737
741
class MainController extends Controller
738
742
{
739
743
/**
740
- * @Route("/{_locale}", defaults={"_locale": "en"}, requirements={"_locale": "en|fr"})
744
+ * @Route("/{_locale}", defaults={"_locale": "en"}, requirements={
745
+ * "_locale": "en|fr"
746
+ * })
741
747
*/
742
748
public function homepageAction($_locale)
743
749
{
@@ -1018,8 +1024,12 @@ routing system can be:
1018
1024
/**
1019
1025
* @Route(
1020
1026
* "/articles/{_locale}/{year}/{title}.{_format}",
1021
- * defaults: {"_format": "html"}
1022
- * requirements: {"_locale": "en|fr", "_format": "html|rss", "year": "\d+"}
1027
+ * defaults: {"_format": "html"},
1028
+ * requirements: {
1029
+ * "_locale": "en|fr",
1030
+ * "_format": "html|rss",
1031
+ * "year": "\d+"
1032
+ * }
1023
1033
* )
1024
1034
*/
1025
1035
public function showAction($_locale, $year, $title)
@@ -1096,7 +1106,7 @@ a slash. URLs matching this route might look like:
1096
1106
This example also highlights the special ``_format `` routing parameter.
1097
1107
When using this parameter, the matched value becomes the "request format"
1098
1108
of the ``Request `` object. Ultimately, the request format is used for such
1099
- things such as setting the ``Content-Type `` of the response (e.g. a ``json ``
1109
+ things as setting the ``Content-Type `` of the response (e.g. a ``json ``
1100
1110
request format translates into a ``Content-Type `` of ``application/json ``).
1101
1111
It can also be used in the controller to render a different template for
1102
1112
each value of ``_format ``. The ``_format `` parameter is a very powerful way
@@ -1188,7 +1198,7 @@ each is made available as an argument to the controller method::
1188
1198
1189
1199
public function showAction($slug)
1190
1200
{
1191
- // ...
1201
+ // ...
1192
1202
}
1193
1203
1194
1204
In reality, the entire ``defaults `` collection is merged with the parameter
@@ -1263,8 +1273,8 @@ configuration:
1263
1273
1264
1274
$collection = new RouteCollection();
1265
1275
$collection->addCollection(
1266
- // second argument is the type, which is required to enable the annotation reader
1267
- // for this resource
1276
+ // second argument is the type, which is required to enable
1277
+ // the annotation reader for this resource
1268
1278
$loader->import("@AppBundle/Controller/", "annotation")
1269
1279
);
1270
1280
@@ -1354,7 +1364,7 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
1354
1364
// app/config/routing.php
1355
1365
use Symfony\Component\Routing\RouteCollection;
1356
1366
1357
- $app = $loader->import('@AppBundle/Controller/');
1367
+ $app = $loader->import('@AppBundle/Controller/', 'annotation' );
1358
1368
$app->addPrefix('/site');
1359
1369
1360
1370
$collection = new RouteCollection();
@@ -1440,7 +1450,9 @@ system. Take the ``blog_show`` example route from earlier::
1440
1450
// '_controller' => 'AppBundle:Blog:show',
1441
1451
// )
1442
1452
1443
- $uri = $this->get('router')->generate('blog_show', array('slug' => 'my-blog-post'));
1453
+ $uri = $this->get('router')->generate('blog_show', array(
1454
+ 'slug' => 'my-blog-post'
1455
+ ));
1444
1456
// /blog/my-blog-post
1445
1457
1446
1458
To generate a URL, you need to specify the name of the route (e.g. ``blog_show ``)
@@ -1508,7 +1520,10 @@ Generating URLs with Query Strings
1508
1520
The ``generate `` method takes an array of wildcard values to generate the URI.
1509
1521
But if you pass extra ones, they will be added to the URI as a query string::
1510
1522
1511
- $this->get('router')->generate('blog', array('page' => 2, 'category' => 'Symfony'));
1523
+ $this->get('router')->generate('blog', array(
1524
+ 'page' => 2,
1525
+ 'category' => 'Symfony'
1526
+ ));
1512
1527
// /blog/2?category=Symfony
1513
1528
1514
1529
Generating URLs from a Template
@@ -1549,7 +1564,7 @@ method::
1549
1564
1550
1565
From a template, in Twig, simply use the ``url() `` function (which generates an absolute URL)
1551
1566
rather than the ``path() `` function (which generates a relative URL). In PHP, pass ``true ``
1552
- to ``generateUrl () ``:
1567
+ to ``generate () ``:
1553
1568
1554
1569
.. configuration-block ::
1555
1570
0 commit comments