Skip to content

Commit 433ca2b

Browse files
committed
Merge branch 'improve_code' of github.com:WouterJ/symfony-docs into WouterJ-improve_code
Conflicts: cookbook/bundles/extension.rst
2 parents 7d03090 + 2094e16 commit 433ca2b

40 files changed

+267
-180
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
@@ -390,7 +390,7 @@ method::
390390
public function getDefaultOptions(array $options)
391391
{
392392
return array(
393-
'validation_groups' => array('registration')
393+
'validation_groups' => array('registration'),
394394
);
395395
}
396396

@@ -1222,9 +1222,11 @@ file:
12221222
12231223
// app/config/config.php
12241224
$container->loadFromExtension('twig', array(
1225-
'form' => array('resources' => array(
1226-
'AcmeTaskBundle:Form:fields.html.twig',
1227-
))
1225+
'form' => array(
1226+
'resources' => array(
1227+
'AcmeTaskBundle:Form:fields.html.twig',
1228+
),
1229+
),
12281230
// ...
12291231
));
12301232
@@ -1301,10 +1303,13 @@ file:
13011303
13021304
// app/config/config.php
13031305
$container->loadFromExtension('framework', array(
1304-
'templating' => array('form' =>
1305-
array('resources' => array(
1306-
'AcmeTaskBundle:Form',
1307-
)))
1306+
'templating' => array(
1307+
'form' => array(
1308+
'resources' => array(
1309+
'AcmeTaskBundle:Form',
1310+
),
1311+
),
1312+
)
13081313
// ...
13091314
));
13101315

book/http_cache.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ First, to use ESI, be sure to enable it in your application configuration:
851851
852852
// app/config/config.php
853853
$container->loadFromExtension('framework', array(
854-
// ...
854+
...,
855855
'esi' => array('enabled' => true),
856856
));
857857
@@ -890,7 +890,7 @@ matter), Symfony2 uses the standard ``render`` helper to configure ESI tags:
890890
$view['router']->generate('latest_news', array('max' => 5), true),
891891
array(),
892892
array('standalone' => true)
893-
) ?>
893+
); ?>
894894
895895
.. include:: /book/_security-2012-6431.rst.inc
896896

book/internals.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,9 @@ the configuration for the development environment:
539539
540540
// enable the web profiler
541541
$container->loadFromExtension('web_profiler', array(
542-
'toolbar' => true,
542+
'toolbar' => true,
543543
'intercept-redirects' => true,
544-
'verbose' => true,
544+
'verbose' => true,
545545
));
546546
547547
When ``only-exceptions`` is set to ``true``, the profiler only collects data

book/page_creation.rst

Lines changed: 3 additions & 4 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
// ...
@@ -653,8 +653,7 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class::
653653
public function registerBundles()
654654
{
655655
$bundles = array(
656-
// ...
657-
656+
...,
658657
// register your bundles
659658
new Acme\TestBundle\AcmeTestBundle(),
660659
);
@@ -792,7 +791,7 @@ format you prefer:
792791
'csrf-protection' => array(),
793792
'validation' => array('annotations' => true),
794793
'templating' => array(
795-
'engines' => array('twig'),
794+
'engines' => array('twig'),
796795
#'assets_version' => "SomeVersionScheme",
797796
),
798797
'session' => array(

book/routing.rst

Lines changed: 8 additions & 8 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;
@@ -1069,7 +1069,7 @@ system. Take the ``blog_show`` example route from earlier::
10691069

10701070
$params = $this->get('router')->match('/blog/my-blog-post');
10711071
// array(
1072-
// 'slug' => 'my-blog-post',
1072+
// 'slug' => 'my-blog-post',
10731073
// '_controller' => 'AcmeBlogBundle:Blog:show',
10741074
// )
10751075

book/security.rst

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ authentication (i.e. the old-school username/password box):
9898
$container->loadFromExtension('security', array(
9999
'firewalls' => array(
100100
'secured_area' => array(
101-
'pattern' => '^/',
102-
'anonymous' => array(),
101+
'pattern' => '^/',
102+
'anonymous' => array(),
103103
'http_basic' => array(
104-
'realm' => 'Secured Demo Area',
104+
'realm' => 'Secured Demo Area',
105105
),
106106
),
107107
),
@@ -111,8 +111,8 @@ authentication (i.e. the old-school username/password box):
111111
'providers' => array(
112112
'in_memory' => array(
113113
'users' => array(
114-
'ryan' => array('password' => 'ryanpass', 'roles' => 'ROLE_USER'),
115-
'admin' => array('password' => 'kitten', 'roles' => 'ROLE_ADMIN'),
114+
'ryan' => array('password' => 'ryanpass', 'roles' => 'ROLE_USER'),
115+
'admin' => array('password' => 'kitten', 'roles' => 'ROLE_ADMIN'),
116116
),
117117
),
118118
),
@@ -321,8 +321,8 @@ First, enable form login under your firewall:
321321
$container->loadFromExtension('security', array(
322322
'firewalls' => array(
323323
'secured_area' => array(
324-
'pattern' => '^/',
325-
'anonymous' => array(),
324+
'pattern' => '^/',
325+
'anonymous' => array(),
326326
'form_login' => array(
327327
'login_path' => '/login',
328328
'check_path' => '/login_check',
@@ -636,11 +636,11 @@ see :doc:`/cookbook/security/form_login`.
636636
637637
'firewalls' => array(
638638
'login_firewall' => array(
639-
'pattern' => '^/login$',
639+
'pattern' => '^/login$',
640640
'anonymous' => array(),
641641
),
642642
'secured_area' => array(
643-
'pattern' => '^/',
643+
'pattern' => '^/',
644644
'form_login' => array(),
645645
),
646646
),
@@ -723,7 +723,7 @@ You can define as many URL patterns as you need - each is a regular expression.
723723
724724
// app/config/security.php
725725
$container->loadFromExtension('security', array(
726-
// ...
726+
...,
727727
'access_control' => array(
728728
array('path' => '^/admin/users', 'role' => 'ROLE_SUPER_ADMIN'),
729729
array('path' => '^/admin', 'role' => 'ROLE_ADMIN'),
@@ -1072,12 +1072,12 @@ In fact, you've seen this already in the example in this chapter.
10721072
10731073
// app/config/security.php
10741074
$container->loadFromExtension('security', array(
1075-
// ...
1075+
...,
10761076
'providers' => array(
10771077
'default_provider' => array(
10781078
'users' => array(
1079-
'ryan' => array('password' => 'ryanpass', 'roles' => 'ROLE_USER'),
1080-
'admin' => array('password' => 'kitten', 'roles' => 'ROLE_ADMIN'),
1079+
'ryan' => array('password' => 'ryanpass', 'roles' => 'ROLE_USER'),
1080+
'admin' => array('password' => 'kitten', 'roles' => 'ROLE_ADMIN'),
10811081
),
10821082
),
10831083
),
@@ -1253,7 +1253,7 @@ do the following:
12531253
'providers' => array(
12541254
'in_memory' => array(
12551255
'users' => array(
1256-
'ryan' => array('password' => 'bb87a29949f3a1ee0559f8a57357487151281386', 'roles' => 'ROLE_USER'),
1256+
'ryan' => array('password' => 'bb87a29949f3a1ee0559f8a57357487151281386', 'roles' => 'ROLE_USER'),
12571257
'admin' => array('password' => '74913f5cd5f61ec0bcfdb775414c2fb3d161b620', 'roles' => 'ROLE_ADMIN'),
12581258
),
12591259
),
@@ -1302,8 +1302,7 @@ configure the encoder for that user:
13021302
13031303
// app/config/security.php
13041304
$container->loadFromExtension('security', array(
1305-
// ...
1306-
1305+
...,
13071306
'encoders' => array(
13081307
'Acme\UserBundle\Entity\User' => 'sha512',
13091308
),
@@ -1503,10 +1502,10 @@ the first provider is always used:
15031502
$container->loadFromExtension('security', array(
15041503
'firewalls' => array(
15051504
'secured_area' => array(
1506-
// ...
1505+
...,
15071506
'provider' => 'user_db',
15081507
'http_basic' => array(
1509-
// ...
1508+
...,
15101509
'provider' => 'in_memory',
15111510
),
15121511
'form_login' => array(),
@@ -1617,7 +1616,7 @@ the firewall can handle this automatically for you when you activate the
16171616
$container->loadFromExtension('security', array(
16181617
'firewalls' => array(
16191618
'secured_area' => array(
1620-
// ...
1619+
...,
16211620
'logout' => array('path' => 'logout', 'target' => '/'),
16221621
),
16231622
),
@@ -1772,7 +1771,7 @@ done by activating the ``switch_user`` firewall listener:
17721771
$container->loadFromExtension('security', array(
17731772
'firewalls' => array(
17741773
'main'=> array(
1775-
// ...
1774+
...,
17761775
'switch_user' => true
17771776
),
17781777
),
@@ -1806,7 +1805,11 @@ to show a link to exit impersonation:
18061805
.. code-block:: html+php
18071806

18081807
<?php if ($view['security']->isGranted('ROLE_PREVIOUS_ADMIN')): ?>
1809-
<a href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>">Exit impersonation</a>
1808+
<a
1809+
href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>"
1810+
>
1811+
Exit impersonation
1812+
</a>
18101813
<?php endif; ?>
18111814

18121815
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
@@ -727,7 +727,7 @@ Injecting the dependency by the setter method just needs a change of syntax:
727727
$container->setDefinition('newsletter_manager', new Definition(
728728
'%newsletter_manager.class%'
729729
))->addMethodCall('setMailer', array(
730-
new Reference('my_mailer')
730+
new Reference('my_mailer'),
731731
));
732732
733733
.. note::
@@ -788,10 +788,12 @@ it exists and do nothing if it doesn't:
788788
$container->setDefinition('my_mailer', ...);
789789
$container->setDefinition('newsletter_manager', new Definition(
790790
'%newsletter_manager.class%',
791-
array(new Reference(
792-
'my_mailer',
793-
ContainerInterface::IGNORE_ON_INVALID_REFERENCE
794-
))
791+
array(
792+
new Reference(
793+
'my_mailer',
794+
ContainerInterface::IGNORE_ON_INVALID_REFERENCE
795+
)
796+
)
795797
));
796798
797799
In YAML, the special ``@?`` syntax tells the service container that the dependency
@@ -875,7 +877,7 @@ Configuring the service container is easy:
875877
'%newsletter_manager.class%',
876878
array(
877879
new Reference('mailer'),
878-
new Reference('templating')
880+
new Reference('templating'),
879881
)
880882
));
881883

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

book/testing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,10 @@ or perform more complex requests::
354354
// or
355355
$photo = array(
356356
'tmp_name' => '/path/to/photo.jpg',
357-
'name' => 'photo.jpg',
358-
'type' => 'image/jpeg',
359-
'size' => 123,
360-
'error' => UPLOAD_ERR_OK
357+
'name' => 'photo.jpg',
358+
'type' => 'image/jpeg',
359+
'size' => 123,
360+
'error' => UPLOAD_ERR_OK
361361
);
362362
$client->request(
363363
'POST',

0 commit comments

Comments
 (0)