Skip to content

Commit ae25cdb

Browse files
committed
Merge pull request #2749 from WouterJ/book_examples_scroll
[book] Avoid scrollbars in code examples
2 parents 41e12da + 87b9556 commit ae25cdb

13 files changed

+353
-126
lines changed

book/controller.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,10 @@ For example, imagine you're processing a form submit::
669669
if ($form->isValid()) {
670670
// do some sort of processing
671671

672-
$this->get('session')->getFlashBag()->add('notice', 'Your changes were saved!');
672+
$this->get('session')->getFlashBag()->add(
673+
'notice',
674+
'Your changes were saved!'
675+
);
673676

674677
return $this->redirect($this->generateUrl(...));
675678
}

book/doctrine.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ just a simple PHP class.
212212

213213
.. code-block:: bash
214214
215-
$ php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Product" --fields="name:string(255) price:float description:text"
215+
$ php app/console doctrine:generate:entity \
216+
--entity="AcmeStoreBundle:Product" \
217+
--fields="name:string(255) price:float description:text"
216218
217219
.. index::
218220
single: Doctrine; Adding mapping metadata
@@ -696,7 +698,10 @@ a controller, do the following::
696698

697699
$em = $this->getDoctrine()->getManager();
698700
$query = $em->createQuery(
699-
'SELECT p FROM AcmeStoreBundle:Product p WHERE p.price > :price ORDER BY p.price ASC'
701+
'SELECT p
702+
FROM AcmeStoreBundle:Product p
703+
WHERE p.price > :price
704+
ORDER BY p.price ASC'
700705
)->setParameter('price', '19.99');
701706

702707
$products = $query->getResult();
@@ -858,7 +863,9 @@ ordered alphabetically.
858863
public function findAllOrderedByName()
859864
{
860865
return $this->getEntityManager()
861-
->createQuery('SELECT p FROM AcmeStoreBundle:Product p ORDER BY p.name ASC')
866+
->createQuery(
867+
'SELECT p FROM AcmeStoreBundle:Product p ORDER BY p.name ASC'
868+
)
862869
->getResult();
863870
}
864871
}
@@ -892,7 +899,8 @@ you can let Doctrine create the class for you.
892899

893900
.. code-block:: bash
894901
895-
$ php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Category" --fields="name:string(255)"
902+
$ php app/console doctrine:generate:entity --entity="AcmeStoreBundle:Category" \
903+
--fields="name:string(255)"
896904
897905
This task generates the ``Category`` entity for you, with an ``id`` field,
898906
a ``name`` field and the associated getter and setter functions.
@@ -937,7 +945,7 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
937945
products:
938946
targetEntity: Product
939947
mappedBy: category
940-
# don't forget to init the collection in entity __construct() method
948+
# don't forget to init the collection in the __construct() method of the entity
941949
942950
.. code-block:: xml
943951
@@ -954,7 +962,10 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
954962
mapped-by="category"
955963
/>
956964
957-
<!-- don't forget to init the collection in entity __construct() method -->
965+
<!--
966+
don't forget to init the collection in
967+
the __construct() method of the entity
968+
-->
958969
</entity>
959970
</doctrine-mapping>
960971
@@ -1325,7 +1336,8 @@ the current date, only when the entity is first persisted (i.e. inserted):
13251336
<entity name="Acme\StoreBundle\Entity\Product">
13261337
<!-- ... -->
13271338
<lifecycle-callbacks>
1328-
<lifecycle-callback type="prePersist" method="setCreatedValue" />
1339+
<lifecycle-callback type="prePersist"
1340+
method="setCreatedValue" />
13291341
</lifecycle-callbacks>
13301342
</entity>
13311343
</doctrine-mapping>

book/forms.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,10 @@ object.
347347
$metadata->addPropertyConstraint('task', new NotBlank());
348348
349349
$metadata->addPropertyConstraint('dueDate', new NotBlank());
350-
$metadata->addPropertyConstraint('dueDate', new Type('\DateTime'));
350+
$metadata->addPropertyConstraint(
351+
'dueDate',
352+
new Type('\DateTime')
353+
);
351354
}
352355
}
353356
@@ -427,7 +430,10 @@ to an array callback, or a ``Closure``::
427430
public function setDefaultOptions(OptionsResolverInterface $resolver)
428431
{
429432
$resolver->setDefaults(array(
430-
'validation_groups' => array('Acme\\AcmeBundle\\Entity\\Client', 'determineValidationGroups'),
433+
'validation_groups' => array(
434+
'Acme\AcmeBundle\Entity\Client',
435+
'determineValidationGroups',
436+
),
431437
));
432438
}
433439

@@ -906,7 +912,8 @@ easy to use in your application.
906912
.. code-block:: xml
907913
908914
<!-- src/Acme/TaskBundle/Resources/config/services.xml -->
909-
<service id="acme_demo.form.type.task" class="Acme\TaskBundle\Form\Type\TaskType">
915+
<service id="acme_demo.form.type.task"
916+
class="Acme\TaskBundle\Form\Type\TaskType">
910917
<tag name="form.type" alias="task" />
911918
</service>
912919
@@ -916,7 +923,10 @@ easy to use in your application.
916923
use Symfony\Component\DependencyInjection\Definition;
917924
918925
$container
919-
->register('acme_demo.form.type.task', 'Acme\TaskBundle\Form\Type\TaskType')
926+
->register(
927+
'acme_demo.form.type.task',
928+
'Acme\TaskBundle\Form\Type\TaskType'
929+
)
920930
->addTag('form.type', array(
921931
'alias' => 'task',
922932
))
@@ -1289,13 +1299,13 @@ rendered (e.g. ``label``, ``widget``, ``errors``, etc). By default, there
12891299
are 4 possible *parts* of a form that can be rendered:
12901300

12911301
+-------------+--------------------------+---------------------------------------------------------+
1292-
| ``label`` | (e.g. ``form_label``) | renders the field's label |
1302+
| ``label`` | (e.g. ``form_label``) | renders the field's label |
12931303
+-------------+--------------------------+---------------------------------------------------------+
1294-
| ``widget`` | (e.g. ``form_widget``) | renders the field's HTML representation |
1304+
| ``widget`` | (e.g. ``form_widget``) | renders the field's HTML representation |
12951305
+-------------+--------------------------+---------------------------------------------------------+
1296-
| ``errors`` | (e.g. ``form_errors``) | renders the field's errors |
1306+
| ``errors`` | (e.g. ``form_errors``) | renders the field's errors |
12971307
+-------------+--------------------------+---------------------------------------------------------+
1298-
| ``row`` | (e.g. ``form_row``) | renders the field's entire row (label, widget & errors) |
1308+
| ``row`` | (e.g. ``form_row``) | renders the field's entire row (label, widget & errors) |
12991309
+-------------+--------------------------+---------------------------------------------------------+
13001310

13011311
.. note::

book/installation.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Distribution:
5757

5858
.. code-block:: bash
5959
60-
php composer.phar create-project symfony/framework-standard-edition /path/to/webroot/Symfony 2.2.0
60+
$ php composer.phar create-project \
61+
symfony/framework-standard-edition /path/to/webroot/Symfony 2.2.0
6162
6263
.. tip::
6364

book/internals.rst

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,11 @@ and set a new ``Exception`` object, or do nothing::
418418
response won't work. If you want to overwrite the status code (which you
419419
should not without a good reason), set the ``X-Status-Code`` header::
420420

421-
return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200));
421+
return new Response(
422+
'Error',
423+
404 // ignored,
424+
array('X-Status-Code' => 200)
425+
);
422426

423427
.. index::
424428
single: Event Dispatcher
@@ -610,11 +614,19 @@ If you enable the web profiler, you also need to mount the profiler routes:
610614
611615
.. code-block:: xml
612616
613-
<import resource="@WebProfilerBundle/Resources/config/routing/profiler.xml" prefix="/_profiler" />
617+
<import
618+
resource="@WebProfilerBundle/Resources/config/routing/profiler.xml"
619+
prefix="/_profiler"
620+
/>
614621
615622
.. code-block:: php
616623
617-
$collection->addCollection($loader->import("@WebProfilerBundle/Resources/config/routing/profiler.xml"), '/_profiler');
624+
$collection->addCollection(
625+
$loader->import(
626+
"@WebProfilerBundle/Resources/config/routing/profiler.xml"
627+
),
628+
'/_profiler'
629+
);
618630
619631
As the profiler adds some overhead, you might want to enable it only under
620632
certain circumstances in the production environment. The ``only-exceptions``
@@ -626,7 +638,8 @@ portion of the website? You can use a request matcher:
626638

627639
.. code-block:: yaml
628640
629-
# enables the profiler only for request coming for the 192.168.0.0 network
641+
# enables the profiler only for request coming
642+
# for the 192.168.0.0 network
630643
framework:
631644
profiler:
632645
matcher: { ip: 192.168.0.0/24 }
@@ -641,14 +654,18 @@ portion of the website? You can use a request matcher:
641654
profiler:
642655
matcher: { ip: 192.168.0.0/24, path: "^/admin/" }
643656
644-
# use a custom matcher instance defined in the "custom_matcher" service
657+
# use a custom matcher instance defined in
658+
# the "custom_matcher" service
645659
framework:
646660
profiler:
647661
matcher: { service: custom_matcher }
648662
649663
.. code-block:: xml
650664
651-
<!-- enables the profiler only for request coming for the 192.168.0.0 network -->
665+
<!--
666+
enables the profiler only for request coming
667+
for the 192.168.0.0 network
668+
-->
652669
<framework:config>
653670
<framework:profiler>
654671
<framework:matcher ip="192.168.0.0/24" />
@@ -669,7 +686,10 @@ portion of the website? You can use a request matcher:
669686
</framework:profiler>
670687
</framework:config>
671688
672-
<!-- use a custom matcher instance defined in the "custom_matcher" service -->
689+
<!--
690+
use a custom matcher instance defined in
691+
the "custom_matcher" service
692+
-->
673693
<framework:config>
674694
<framework:profiler>
675695
<framework:matcher service="custom_matcher" />
@@ -678,7 +698,8 @@ portion of the website? You can use a request matcher:
678698
679699
.. code-block:: php
680700
681-
// enables the profiler only for request coming for the 192.168.0.0 network
701+
// enables the profiler only for request coming
702+
// for the 192.168.0.0 network
682703
$container->loadFromExtension('framework', array(
683704
'profiler' => array(
684705
'matcher' => array('ip' => '192.168.0.0/24'),
@@ -695,11 +716,15 @@ portion of the website? You can use a request matcher:
695716
// combine rules
696717
$container->loadFromExtension('framework', array(
697718
'profiler' => array(
698-
'matcher' => array('ip' => '192.168.0.0/24', 'path' => '^/admin/'),
719+
'matcher' => array(
720+
'ip' => '192.168.0.0/24',
721+
'path' => '^/admin/',
722+
),
699723
),
700724
));
701725
702-
# use a custom matcher instance defined in the "custom_matcher" service
726+
// use a custom matcher instance defined in
727+
// the "custom_matcher" service
703728
$container->loadFromExtension('framework', array(
704729
'profiler' => array(
705730
'matcher' => array('service' => 'custom_matcher'),

book/page_creation.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ an entry when you generated the ``AcmeHelloBundle``:
114114
115115
<routes xmlns="http://symfony.com/schema/routing"
116116
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
117-
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
117+
xsi:schemaLocation="http://symfony.com/schema/routing
118+
http://symfony.com/schema/routing/routing-1.0.xsd">
118119
119-
<import resource="@AcmeHelloBundle/Resources/config/routing.xml" prefix="/" />
120+
<import resource="@AcmeHelloBundle/Resources/config/routing.xml"
121+
prefix="/" />
120122
</routes>
121123
122124
.. code-block:: php
@@ -157,7 +159,8 @@ the new route that defines the URL of the page that you're about to create:
157159
158160
<routes xmlns="http://symfony.com/schema/routing"
159161
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
160-
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
162+
xsi:schemaLocation="http://symfony.com/schema/routing
163+
http://symfony.com/schema/routing/routing-1.0.xsd">
161164
162165
<route id="hello" path="/hello/{name}">
163166
<default key="_controller">AcmeHelloBundle:Hello:index</default>
@@ -771,7 +774,9 @@ format you prefer:
771774
772775
$container->loadFromExtension('framework', array(
773776
'secret' => '%secret%',
774-
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
777+
'router' => array(
778+
'resource' => '%kernel.root_dir%/config/routing.php',
779+
),
775780
// ...
776781
),
777782
));
@@ -940,7 +945,9 @@ the configuration file for the ``dev`` environment.
940945
</imports>
941946
942947
<framework:config>
943-
<framework:router resource="%kernel.root_dir%/config/routing_dev.xml" />
948+
<framework:router
949+
resource="%kernel.root_dir%/config/routing_dev.xml"
950+
/>
944951
<framework:profiler only-exceptions="false" />
945952
</framework:config>
946953
@@ -952,7 +959,9 @@ the configuration file for the ``dev`` environment.
952959
$loader->import('config.php');
953960
954961
$container->loadFromExtension('framework', array(
955-
'router' => array('resource' => '%kernel.root_dir%/config/routing_dev.php'),
962+
'router' => array(
963+
'resource' => '%kernel.root_dir%/config/routing_dev.php',
964+
),
956965
'profiler' => array('only-exceptions' => false),
957966
));
958967

book/performance.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ as comments in this file::
7979
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
8080

8181
// Use APC for autoloading to improve performance
82-
// Change 'sf2' by the prefix you want in order to prevent key conflict with another application
82+
// Change 'sf2' by the prefix you want in order
83+
// to prevent key conflict with another application
8384
/*
8485
$loader = new ApcClassLoader('sf2', $loader);
8586
$loader->register(true);

book/propel.rst

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,22 +304,46 @@ Start by adding the ``category`` definition in your ``schema.xml``:
304304

305305
.. code-block:: xml
306306
307-
<database name="default" namespace="Acme\StoreBundle\Model" defaultIdMethod="native">
307+
<database name="default"
308+
namespace="Acme\StoreBundle\Model"
309+
defaultIdMethod="native">
308310
<table name="product">
309-
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
310-
<column name="name" type="varchar" primaryString="true" size="100" />
311-
<column name="price" type="decimal" />
312-
<column name="description" type="longvarchar" />
311+
<column name="id"
312+
type="integer"
313+
required="true"
314+
primaryKey="true"
315+
autoIncrement="true" />
316+
317+
<column name="name"
318+
type="varchar"
319+
primaryString="true"
320+
size="100" />
321+
322+
<column name="price"
323+
type="decimal" />
324+
325+
<column name="description"
326+
type="longvarchar" />
327+
328+
<column name="category_id"
329+
type="integer" />
313330
314-
<column name="category_id" type="integer" />
315331
<foreign-key foreignTable="category">
316332
<reference local="category_id" foreign="id" />
317333
</foreign-key>
318334
</table>
319335
320336
<table name="category">
321-
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
322-
<column name="name" type="varchar" primaryString="true" size="100" />
337+
<column name="id"
338+
type="integer"
339+
required="true"
340+
primaryKey="true"
341+
autoIncrement="true" />
342+
343+
<column name="name"
344+
type="varchar"
345+
primaryString="true"
346+
size="100" />
323347
</table>
324348
</database>
325349

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy