Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe35ecc

Browse files
committed
Merge branch '2.0' into 2.1
Conflicts: book/forms.rst book/page_creation.rst book/security.rst cookbook/form/create_custom_field_type.rst cookbook/security/custom_authentication_provider.rst cookbook/symfony1.rst reference/configuration/security.rst
2 parents a0be65e + 433ca2b commit fe35ecc

Some content is hidden

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

48 files changed

+442
-191
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -892,7 +892,7 @@ matter), Symfony2 uses the standard ``render`` helper to configure ESI tags:
892892
<?php echo $view['actions']->render(
893893
$view['router']->generate('latest_news', array('max' => 5), true),
894894
array('standalone' => true)
895-
) ?>
895+
); ?>
896896
897897
.. include:: /book/_security-2012-6431.rst.inc
898898

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
@@ -171,7 +171,7 @@ file:
171171
// app/config/config.php
172172
$container->loadFromExtension('framework', array(
173173
// ...
174-
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
174+
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
175175
));
176176
177177
.. tip::
@@ -397,7 +397,7 @@ This is done by including it in the ``defaults`` collection:
397397
$collection = new RouteCollection();
398398
$collection->add('blog', new Route('/blog/{page}', array(
399399
'_controller' => 'AcmeBlogBundle:Blog:index',
400-
'page' => 1,
400+
'page' => 1,
401401
)));
402402
403403
return $collection;
@@ -466,7 +466,7 @@ Take a quick look at the routes that have been created so far:
466466
$collection = new RouteCollection();
467467
$collection->add('blog', new Route('/blog/{page}', array(
468468
'_controller' => 'AcmeBlogBundle:Blog:index',
469-
'page' => 1,
469+
'page' => 1,
470470
)));
471471
472472
$collection->add('blog_show', new Route('/blog/{show}', array(
@@ -528,7 +528,7 @@ requirements can easily be added for each parameter. For example:
528528
$collection = new RouteCollection();
529529
$collection->add('blog', new Route('/blog/{page}', array(
530530
'_controller' => 'AcmeBlogBundle:Blog:index',
531-
'page' => 1,
531+
'page' => 1,
532532
), array(
533533
'page' => '\d+',
534534
)));
@@ -598,7 +598,7 @@ URL:
598598
$collection = new RouteCollection();
599599
$collection->add('homepage', new Route('/{culture}', array(
600600
'_controller' => 'AcmeDemoBundle:Main:homepage',
601-
'culture' => 'en',
601+
'culture' => 'en',
602602
), array(
603603
'culture' => 'en|fr',
604604
)));
@@ -747,11 +747,11 @@ routing system can be:
747747
$collection = new RouteCollection();
748748
$collection->add('homepage', new Route('/articles/{culture}/{year}/{title}.{_format}', array(
749749
'_controller' => 'AcmeDemoBundle:Article:show',
750-
'_format' => 'html',
750+
'_format' => 'html',
751751
), array(
752752
'culture' => 'en|fr',
753753
'_format' => 'html|rss',
754-
'year' => '\d+',
754+
'year' => '\d+',
755755
)));
756756
757757
return $collection;
@@ -1089,13 +1089,13 @@ a route+parameters back to a URL. The
10891089
:method:`Symfony\\Component\\Routing\\Router::generate` methods form this bi-directional
10901090
system. Take the ``blog_show`` example route from earlier::
10911091

1092-
$params = $router->match('/blog/my-blog-post');
1092+
$params = $this->get('router')->match('/blog/my-blog-post');
10931093
// array(
1094-
// 'slug' => 'my-blog-post',
1094+
// 'slug' => 'my-blog-post',
10951095
// '_controller' => 'AcmeBlogBundle:Blog:show',
10961096
// )
10971097

1098-
$uri = $router->generate('blog_show', array('slug' => 'my-blog-post'));
1098+
$uri = $this->get('router')->generate('blog_show', array('slug' => 'my-blog-post'));
10991099
// /blog/my-blog-post
11001100

11011101
To generate a URL, you need to specify the name of the route (e.g. ``blog_show``)
@@ -1108,13 +1108,22 @@ that route. With this information, any URL can easily be generated::
11081108
{
11091109
// ...
11101110

1111-
$url = $this->get('router')->generate(
1111+
$url = $this->generateUrl(
11121112
'blog_show',
11131113
array('slug' => 'my-blog-post')
11141114
);
11151115
}
11161116
}
11171117

1118+
.. note::
1119+
1120+
In controllers that extend Symfony's base
1121+
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`,
1122+
you can use the
1123+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl`
1124+
method, which call's the router service's
1125+
:method:`Symfony\\Component\\Routing\\Router::generate` method.
1126+
11181127
In an upcoming section, you'll learn how to generate URLs from inside templates.
11191128

11201129
.. tip::

book/security.rst

Lines changed: 24 additions & 17 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'),
@@ -1080,7 +1084,7 @@ In fact, you've seen this already in the example in this chapter.
10801084
10811085
// app/config/security.php
10821086
$container->loadFromExtension('security', array(
1083-
// ...
1087+
...,
10841088
'providers' => array(
10851089
'default_provider' => array(
10861090
'memory' => array(
@@ -1323,8 +1327,7 @@ configure the encoder for that user:
13231327
13241328
// app/config/security.php
13251329
$container->loadFromExtension('security', array(
1326-
// ...
1327-
1330+
...,
13281331
'encoders' => array(
13291332
'Acme\UserBundle\Entity\User' => 'sha512',
13301333
),
@@ -1551,10 +1554,10 @@ the first provider is always used:
15511554
$container->loadFromExtension('security', array(
15521555
'firewalls' => array(
15531556
'secured_area' => array(
1554-
// ...
1557+
...,
15551558
'provider' => 'user_db',
15561559
'http_basic' => array(
1557-
// ...
1560+
...,
15581561
'provider' => 'in_memory',
15591562
),
15601563
'form_login' => array(),
@@ -1825,7 +1828,7 @@ done by activating the ``switch_user`` firewall listener:
18251828
$container->loadFromExtension('security', array(
18261829
'firewalls' => array(
18271830
'main'=> array(
1828-
// ...
1831+
...,
18291832
'switch_user' => true
18301833
),
18311834
),
@@ -1859,7 +1862,11 @@ to show a link to exit impersonation:
18591862
.. code-block:: html+php
18601863

18611864
<?php if ($view['security']->isGranted('ROLE_PREVIOUS_ADMIN')): ?>
1862-
<a href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>">Exit impersonation</a>
1865+
<a
1866+
href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>"
1867+
>
1868+
Exit impersonation
1869+
</a>
18631870
<?php endif; ?>
18641871

18651872
Of course, this feature needs to be made available to a small group of users.

book/service_container.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ arrays.
300300
use Symfony\Component\DependencyInjection\Definition;
301301
302302
$container->setParameter('my_mailer.gateways', array('mail1', 'mail2', 'mail3'));
303-
$container->setParameter('my_multilang.language_fallback',
304-
array('en' => array('en', 'fr'),
305-
'fr' => array('fr', 'en'),
306-
));
303+
$container->setParameter('my_multilang.language_fallback', array(
304+
'en' => array('en', 'fr'),
305+
'fr' => array('fr', 'en'),
306+
));
307307
308308
309309
Importing other Container Configuration Resources
@@ -725,7 +725,7 @@ Injecting the dependency by the setter method just needs a change of syntax:
725725
$container->setDefinition('newsletter_manager', new Definition(
726726
'%newsletter_manager.class%'
727727
))->addMethodCall('setMailer', array(
728-
new Reference('my_mailer')
728+
new Reference('my_mailer'),
729729
));
730730
731731
.. note::
@@ -786,10 +786,12 @@ it exists and do nothing if it doesn't:
786786
$container->setDefinition('my_mailer', ...);
787787
$container->setDefinition('newsletter_manager', new Definition(
788788
'%newsletter_manager.class%',
789-
array(new Reference(
790-
'my_mailer',
791-
ContainerInterface::IGNORE_ON_INVALID_REFERENCE
792-
))
789+
array(
790+
new Reference(
791+
'my_mailer',
792+
ContainerInterface::IGNORE_ON_INVALID_REFERENCE
793+
)
794+
)
793795
));
794796
795797
In YAML, the special ``@?`` syntax tells the service container that the dependency
@@ -873,7 +875,7 @@ Configuring the service container is easy:
873875
'%newsletter_manager.class%',
874876
array(
875877
new Reference('mailer'),
876-
new Reference('templating')
878+
new Reference('templating'),
877879
)
878880
));
879881

book/templating.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,10 @@ Including this template from any other template is simple:
547547
<h1>Recent Articles</h1>
548548

549549
<?php foreach ($articles as $article): ?>
550-
<?php echo $view->render('AcmeArticleBundle:Article:articleDetails.html.php', array('article' => $article)) ?>
550+
<?php echo $view->render(
551+
'AcmeArticleBundle:Article:articleDetails.html.php',
552+
array('article' => $article)
553+
) ?>
551554
<?php endforeach; ?>
552555
<?php $view['slots']->stop() ?>
553556

0 commit comments

Comments
 (0)