Skip to content

Commit 5246f51

Browse files
committed
Merge branch '2.1'
Conflicts: book/http_cache.rst components/routing/introduction.rst cookbook/security/entity_provider.rst reference/configuration/security.rst
2 parents 24274f0 + fe35ecc commit 5246f51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+849
-241
lines changed

book/controller.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ object that's returned from that controller::
437437
{
438438
$response = $this->forward('AcmeHelloBundle:Hello:fancy', array(
439439
'name' => $name,
440-
'color' => 'green'
440+
'color' => 'green',
441441
));
442442

443443
// ... further modify the response or return it directly

book/forms.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ method::
401401
public function setDefaultOptions(OptionsResolverInterface $resolver)
402402
{
403403
$resolver->setDefaults(array(
404-
'validation_groups' => array('registration')
404+
'validation_groups' => array('registration'),
405405
));
406406
}
407407

@@ -1307,9 +1307,11 @@ file:
13071307
13081308
// app/config/config.php
13091309
$container->loadFromExtension('twig', array(
1310-
'form' => array('resources' => array(
1311-
'AcmeTaskBundle:Form:fields.html.twig',
1312-
))
1310+
'form' => array(
1311+
'resources' => array(
1312+
'AcmeTaskBundle:Form:fields.html.twig',
1313+
),
1314+
),
13131315
// ...
13141316
));
13151317
@@ -1386,10 +1388,13 @@ file:
13861388
13871389
// app/config/config.php
13881390
$container->loadFromExtension('framework', array(
1389-
'templating' => array('form' =>
1390-
array('resources' => array(
1391-
'AcmeTaskBundle:Form',
1392-
)))
1391+
'templating' => array(
1392+
'form' => array(
1393+
'resources' => array(
1394+
'AcmeTaskBundle:Form',
1395+
),
1396+
),
1397+
)
13931398
// ...
13941399
));
13951400

book/http_cache.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ header value::
621621
return $response;
622622
}
623623

624-
// ... do more work to populate the response will the full content
624+
// ... do more work to populate the response with the full content
625625

626626
return $response;
627627
}
@@ -854,7 +854,7 @@ First, to use ESI, be sure to enable it in your application configuration:
854854
855855
// app/config/config.php
856856
$container->loadFromExtension('framework', array(
857-
// ...
857+
...,
858858
'esi' => array('enabled' => true),
859859
));
860860
@@ -900,7 +900,7 @@ matter), Symfony2 uses the standard ``render`` helper to configure ESI tags:
900900
901901
<?php echo $view['actions']->render(
902902
$view['router']->generate('latest_news', array('max' => 5), true),
903-
array('renderer' => 'esi')
903+
array('renderer' => 'esi'),
904904
) ?>
905905
906906
By using the ``esi`` renderer (via the ``render_esi`` Twig function), you

book/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ If there are any issues, correct them now before moving on.
252252

253253
.. code-block:: bash
254254
255-
$ sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
255+
$ sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs
256256
$ sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
257257
258258
**3. Without using ACL**

book/internals.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,9 @@ the configuration for the development environment:
545545
546546
// enable the web profiler
547547
$container->loadFromExtension('web_profiler', array(
548-
'toolbar' => true,
548+
'toolbar' => true,
549549
'intercept-redirects' => true,
550-
'verbose' => true,
550+
'verbose' => true,
551551
));
552552
553553
When ``only-exceptions`` is set to ``true``, the profiler only collects data

book/page_creation.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ the bundle is registered with the kernel::
7777
public function registerBundles()
7878
{
7979
$bundles = array(
80-
// ...
80+
...,
8181
new Acme\HelloBundle\AcmeHelloBundle(),
8282
);
8383
// ...
@@ -648,8 +648,7 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class::
648648
public function registerBundles()
649649
{
650650
$bundles = array(
651-
// ...
652-
651+
...,
653652
// register your bundles
654653
new Acme\TestBundle\AcmeTestBundle(),
655654
);

book/routing.rst

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ file:
175175
// app/config/config.php
176176
$container->loadFromExtension('framework', array(
177177
// ...
178-
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
178+
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
179179
));
180180
181181
.. tip::
@@ -401,7 +401,7 @@ This is done by including it in the ``defaults`` collection:
401401
$collection = new RouteCollection();
402402
$collection->add('blog', new Route('/blog/{page}', array(
403403
'_controller' => 'AcmeBlogBundle:Blog:index',
404-
'page' => 1,
404+
'page' => 1,
405405
)));
406406
407407
return $collection;
@@ -470,7 +470,7 @@ Take a quick look at the routes that have been created so far:
470470
$collection = new RouteCollection();
471471
$collection->add('blog', new Route('/blog/{page}', array(
472472
'_controller' => 'AcmeBlogBundle:Blog:index',
473-
'page' => 1,
473+
'page' => 1,
474474
)));
475475
476476
$collection->add('blog_show', new Route('/blog/{show}', array(
@@ -532,7 +532,7 @@ requirements can easily be added for each parameter. For example:
532532
$collection = new RouteCollection();
533533
$collection->add('blog', new Route('/blog/{page}', array(
534534
'_controller' => 'AcmeBlogBundle:Blog:index',
535-
'page' => 1,
535+
'page' => 1,
536536
), array(
537537
'page' => '\d+',
538538
)));
@@ -602,7 +602,7 @@ URL:
602602
$collection = new RouteCollection();
603603
$collection->add('homepage', new Route('/{culture}', array(
604604
'_controller' => 'AcmeDemoBundle:Main:homepage',
605-
'culture' => 'en',
605+
'culture' => 'en',
606606
), array(
607607
'culture' => 'en|fr',
608608
)));
@@ -754,11 +754,11 @@ routing system can be:
754754
$collection = new RouteCollection();
755755
$collection->add('homepage', new Route('/articles/{culture}/{year}/{title}.{_format}', array(
756756
'_controller' => 'AcmeDemoBundle:Article:show',
757-
'_format' => 'html',
757+
'_format' => 'html',
758758
), array(
759759
'culture' => 'en|fr',
760760
'_format' => 'html|rss',
761-
'year' => '\d+',
761+
'year' => '\d+',
762762
)));
763763
764764
return $collection;
@@ -1105,13 +1105,13 @@ a route+parameters back to a URL. The
11051105
:method:`Symfony\\Component\\Routing\\Router::generate` methods form this bi-directional
11061106
system. Take the ``blog_show`` example route from earlier::
11071107

1108-
$params = $router->match('/blog/my-blog-post');
1108+
$params = $this->get('router')->match('/blog/my-blog-post');
11091109
// array(
1110-
// 'slug' => 'my-blog-post',
1110+
// 'slug' => 'my-blog-post',
11111111
// '_controller' => 'AcmeBlogBundle:Blog:show',
11121112
// )
11131113

1114-
$uri = $router->generate('blog_show', array('slug' => 'my-blog-post'));
1114+
$uri = $this->get('router')->generate('blog_show', array('slug' => 'my-blog-post'));
11151115
// /blog/my-blog-post
11161116

11171117
To generate a URL, you need to specify the name of the route (e.g. ``blog_show``)
@@ -1124,13 +1124,22 @@ route. With this information, any URL can easily be generated::
11241124
{
11251125
// ...
11261126

1127-
$url = $this->get('router')->generate(
1127+
$url = $this->generateUrl(
11281128
'blog_show',
11291129
array('slug' => 'my-blog-post')
11301130
);
11311131
}
11321132
}
11331133

1134+
.. note::
1135+
1136+
In controllers that extend Symfony's base
1137+
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`,
1138+
you can use the
1139+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl`
1140+
method, which call's the router service's
1141+
:method:`Symfony\\Component\\Routing\\Router::generate` method.
1142+
11341143
In an upcoming section, you'll learn how to generate URLs from inside templates.
11351144

11361145
.. tip::

book/security.rst

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ authentication (i.e. the old-school username/password box):
101101
$container->loadFromExtension('security', array(
102102
'firewalls' => array(
103103
'secured_area' => array(
104-
'pattern' => '^/',
105-
'anonymous' => array(),
104+
'pattern' => '^/',
105+
'anonymous' => array(),
106106
'http_basic' => array(
107-
'realm' => 'Secured Demo Area',
107+
'realm' => 'Secured Demo Area',
108108
),
109109
),
110110
),
@@ -153,6 +153,8 @@ Symfony's security system works by determining who a user is (i.e. authenticatio
153153
and then checking to see if that user should have access to a specific resource
154154
or URL.
155155

156+
.. _book-security-firewalls:
157+
156158
Firewalls (Authentication)
157159
~~~~~~~~~~~~~~~~~~~~~~~~~~
158160

@@ -324,8 +326,8 @@ First, enable form login under your firewall:
324326
$container->loadFromExtension('security', array(
325327
'firewalls' => array(
326328
'secured_area' => array(
327-
'pattern' => '^/',
328-
'anonymous' => array(),
329+
'pattern' => '^/',
330+
'anonymous' => array(),
329331
'form_login' => array(
330332
'login_path' => 'login',
331333
'check_path' => 'login_check',
@@ -643,11 +645,11 @@ see :doc:`/cookbook/security/form_login`.
643645
644646
'firewalls' => array(
645647
'login_firewall' => array(
646-
'pattern' => '^/login$',
648+
'pattern' => '^/login$',
647649
'anonymous' => array(),
648650
),
649651
'secured_area' => array(
650-
'pattern' => '^/',
652+
'pattern' => '^/',
651653
'form_login' => array(),
652654
),
653655
),
@@ -664,8 +666,10 @@ see :doc:`/cookbook/security/form_login`.
664666

665667
If you're using multiple firewalls and you authenticate against one firewall,
666668
you will *not* be authenticated against any other firewalls automatically.
667-
Different firewalls are like different security systems. That's why,
668-
for most applications, having one main firewall is enough.
669+
Different firewalls are like different security systems. To do this you have
670+
to explicitly specify the same :ref:`reference-security-firewall-context`
671+
for different firewalls. But usually for most applications, having one
672+
main firewall is enough.
669673

670674
Authorization
671675
-------------
@@ -728,7 +732,7 @@ You can define as many URL patterns as you need - each is a regular expression.
728732
729733
// app/config/security.php
730734
$container->loadFromExtension('security', array(
731-
// ...
735+
...,
732736
'access_control' => array(
733737
array('path' => '^/admin/users', 'role' => 'ROLE_SUPER_ADMIN'),
734738
array('path' => '^/admin', 'role' => 'ROLE_ADMIN'),
@@ -1078,7 +1082,7 @@ In fact, you've seen this already in the example in this chapter.
10781082
10791083
// app/config/security.php
10801084
$container->loadFromExtension('security', array(
1081-
// ...
1085+
...,
10821086
'providers' => array(
10831087
'default_provider' => array(
10841088
'memory' => array(
@@ -1321,8 +1325,7 @@ configure the encoder for that user:
13211325
13221326
// app/config/security.php
13231327
$container->loadFromExtension('security', array(
1324-
// ...
1325-
1328+
...,
13261329
'encoders' => array(
13271330
'Acme\UserBundle\Entity\User' => 'sha512',
13281331
),
@@ -1556,10 +1559,10 @@ the first provider is always used:
15561559
$container->loadFromExtension('security', array(
15571560
'firewalls' => array(
15581561
'secured_area' => array(
1559-
// ...
1562+
...,
15601563
'provider' => 'user_db',
15611564
'http_basic' => array(
1562-
// ...
1565+
...,
15631566
'provider' => 'in_memory',
15641567
),
15651568
'form_login' => array(),
@@ -1830,7 +1833,7 @@ done by activating the ``switch_user`` firewall listener:
18301833
$container->loadFromExtension('security', array(
18311834
'firewalls' => array(
18321835
'main'=> array(
1833-
// ...
1836+
...,
18341837
'switch_user' => true
18351838
),
18361839
),
@@ -1864,7 +1867,11 @@ to show a link to exit impersonation:
18641867
.. code-block:: html+php
18651868

18661869
<?php if ($view['security']->isGranted('ROLE_PREVIOUS_ADMIN')): ?>
1867-
<a href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>">Exit impersonation</a>
1870+
<a
1871+
href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>"
1872+
>
1873+
Exit impersonation
1874+
</a>
18681875
<?php endif; ?>
18691876

18701877
Of course, this feature needs to be made available to a small group of users.
@@ -1900,7 +1907,7 @@ setting:
19001907
$container->loadFromExtension('security', array(
19011908
'firewalls' => array(
19021909
'main'=> array(
1903-
...,
1910+
// ...
19041911
'switch_user' => array('role' => 'ROLE_ADMIN', 'parameter' => '_want_to_be_this_user'),
19051912
),
19061913
),

0 commit comments

Comments
 (0)