Skip to content

Commit c446279

Browse files
committed
Merge branch '2.1' into 2.2
Conflicts: cookbook/configuration/apache_router.rst reference/twig_reference.rst
2 parents 53c4d8e + 3e6be25 commit c446279

37 files changed

+1487
-371
lines changed

book/doctrine.rst

+93-10
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,44 @@ information. By convention, this information is usually configured in an
6464
The parameters defined in that file are referenced by the main configuration
6565
file when setting up Doctrine:
6666

67-
.. code-block:: yaml
68-
69-
# app/config/config.yml
70-
doctrine:
71-
dbal:
72-
driver: "%database_driver%"
73-
host: "%database_host%"
74-
dbname: "%database_name%"
75-
user: "%database_user%"
76-
password: "%database_password%"
67+
.. configuration-block::
68+
69+
.. code-block:: yaml
70+
71+
# app/config/config.yml
72+
doctrine:
73+
dbal:
74+
driver: "%database_driver%"
75+
host: "%database_host%"
76+
dbname: "%database_name%"
77+
user: "%database_user%"
78+
password: "%database_password%"
79+
80+
.. code-block:: xml
81+
82+
<!-- app/config/config.xml -->
83+
<doctrine:config>
84+
<doctrine:dbal
85+
driver="%database_driver%"
86+
host="%database_host%"
87+
dbname="%database_name%"
88+
user="%database_user%"
89+
password="%database_password%"
90+
>
91+
</doctrine:config>
92+
93+
.. code-block:: php
94+
95+
// app/config/config.php
96+
$configuration->loadFromExtension('doctrine', array(
97+
'dbal' => array(
98+
'driver' => '%database_driver%',
99+
'host' => '%database_host%',
100+
'dbname' => '%database_name%',
101+
'user' => '%database_user%',
102+
'password' => '%database_password%',
103+
),
104+
));
77105
78106
By separating the database information into a separate file, you can
79107
easily keep different versions of the file on each server. You can also
@@ -911,6 +939,24 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
911939
mappedBy: category
912940
# don't forget to init the collection in entity __construct() method
913941
942+
.. code-block:: xml
943+
944+
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Category.orm.xml -->
945+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
946+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
947+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
948+
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
949+
950+
<entity name="Acme\StoreBundle\Entity\Category">
951+
<!-- ... -->
952+
<one-to-many field="products"
953+
target-entity="product"
954+
mapped-by="category"
955+
/>
956+
957+
<!-- don't forget to init the collection in entity __construct() method -->
958+
</entity>
959+
</doctrine-mapping>
914960
915961
First, since a ``Category`` object will relate to many ``Product`` objects,
916962
a ``products`` array property is added to hold those ``Product`` objects.
@@ -968,6 +1014,28 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
9681014
name: category_id
9691015
referencedColumnName: id
9701016
1017+
.. code-block:: xml
1018+
1019+
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.xml -->
1020+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
1021+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1022+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
1023+
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
1024+
1025+
<entity name="Acme\StoreBundle\Entity\Product">
1026+
<!-- ... -->
1027+
<many-to-one field="category"
1028+
target-entity="products"
1029+
join-column="category"
1030+
>
1031+
<join-column
1032+
name="category_id"
1033+
referenced-column-name="id"
1034+
/>
1035+
</many-to-one>
1036+
</entity>
1037+
</doctrine-mapping>
1038+
9711039
Finally, now that you've added a new property to both the ``Category`` and
9721040
``Product`` classes, tell Doctrine to generate the missing getter and setter
9731041
methods for you:
@@ -1389,6 +1457,21 @@ and ``nullable``. Take a few examples:
13891457
length: 150
13901458
unique: true
13911459
1460+
.. code-block:: xml
1461+
1462+
<!--
1463+
A string field length 255 that cannot be null
1464+
(reflecting the default values for the "length" and *nullable* options)
1465+
type attribute is necessary in yaml definitions
1466+
-->
1467+
<field name="name" type="string" />
1468+
<field name="email"
1469+
type="string"
1470+
column="email_address"
1471+
length="150"
1472+
unique="true"
1473+
/>
1474+
13921475
.. note::
13931476

13941477
There are a few more options not listed here. For more details, see

book/translation.rst

+13-8
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ Translations in Templates
741741
Most of the time, translation occurs in templates. Symfony2 provides native
742742
support for both Twig and PHP templates.
743743

744-
.. _book-translation-twig:
744+
.. _book-translation-tags:
745745

746746
Twig Templates
747747
~~~~~~~~~~~~~~
@@ -778,6 +778,8 @@ You can also specify the message domain and pass some additional variables:
778778
{0} There is no apples|{1} There is one apple|]1,Inf] There are %count% apples
779779
{% endtranschoice %}
780780
781+
.. _book-translation-filters:
782+
781783
The ``trans`` and ``transchoice`` filters can be used to translate *variable
782784
texts* and complex expressions:
783785

@@ -812,16 +814,19 @@ texts* and complex expressions:
812814
{{ message|trans|raw }}
813815
{{ '<h3>bar</h3>'|trans|raw }}
814816
815-
.. versionadded:: 2.1
816-
You can now set the translation domain for an entire Twig template with a
817-
single tag:
817+
.. tip::
818818

819-
.. code-block:: jinja
819+
You can set the translation domain for an entire Twig template with a single tag:
820820

821-
{% trans_default_domain "app" %}
821+
.. code-block:: jinja
822822
823-
Note that this only influences the current template, not any "included"
824-
templates (in order to avoid side effects).
823+
{% trans_default_domain "app" %}
824+
825+
Note that this only influences the current template, not any "included"
826+
templates (in order to avoid side effects).
827+
828+
.. versionadded:: 2.1
829+
The ``trans_default_domain`` tag is new in Symfony2.1
825830

826831
PHP Templates
827832
~~~~~~~~~~~~~

cookbook/configuration/apache_router.rst

+46-10
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,33 @@ Change Router Configuration Parameters
1313
To dump Apache routes you must first tweak some configuration parameters to tell
1414
Symfony2 to use the ``ApacheUrlMatcher`` instead of the default one:
1515

16-
.. code-block:: yaml
16+
.. configuration-block::
1717

18-
# app/config/config_prod.yml
19-
parameters:
20-
router.options.matcher.cache_class: ~ # disable router cache
21-
router.options.matcher_class: Symfony\Component\Routing\Matcher\ApacheUrlMatcher
18+
.. code-block:: yaml
19+
20+
# app/config/config_prod.yml
21+
parameters:
22+
router.options.matcher.cache_class: ~ # disable router cache
23+
router.options.matcher_class: Symfony\Component\Routing\Matcher\ApacheUrlMatcher
24+
25+
.. code-block:: xml
26+
27+
<!-- app/config/config_prod.xml -->
28+
<parameters>
29+
<parameter key="router.options.matcher.cache_class">null</parameter> <!-- disable router cache -->
30+
<parameter key="router.options.matcher_class">
31+
Symfony\Component\Routing\Matcher\ApacheUrlMatcher
32+
</parameter>
33+
</parameters>
34+
35+
.. code-block:: php
36+
37+
// app/config/config_prod.php
38+
$container->setParameter('router.options.matcher.cache_class', null); // disable router cache
39+
$container->setParameter(
40+
'router.options.matcher_class',
41+
'Symfony\Component\Routing\Matcher\ApacheUrlMatcher'
42+
);
2243
2344
.. tip::
2445

@@ -33,13 +54,28 @@ Generating mod_rewrite rules
3354

3455
To test that it's working, let's create a very basic route for demo bundle:
3556

36-
.. code-block:: yaml
57+
.. configuration-block::
58+
59+
.. code-block:: yaml
60+
61+
# app/config/routing.yml
62+
hello:
63+
pattern: /hello/{name}
64+
defaults: { _controller: AcmeDemoBundle:Demo:hello }
65+
66+
.. code-block:: xml
67+
68+
<!-- app/config/routing.xml -->
69+
<route id="hello" pattern="/hello/{name}">
70+
<default key="_controller">AcmeDemoBundle:Demo:hello</default>
71+
</route>
3772
38-
# app/config/routing.yml
39-
hello:
40-
path: /hello/{name}
41-
defaults: { _controller: AcmeDemoBundle:Demo:hello }
73+
.. code-block:: php
4274
75+
// app/config/routing.php
76+
$collection->add('hello', new Route('/hello/{name}', array(
77+
'_controller' => 'AcmeDemoBundle:Demo:hello',
78+
)));
4379
4480
Now generate **url_rewrite** rules:
4581

cookbook/configuration/external_parameters.rst

+12-4
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,19 @@ key, and define the type as ``constant``.
119119
This only works for XML configuration. If you're *not* using XML, simply
120120
import an XML file to take advantage of this functionality:
121121

122-
.. code-block:: yaml
122+
.. configuration-block::
123+
124+
.. code-block:: yaml
125+
126+
# app/config/config.yml
127+
imports:
128+
- { resource: parameters.xml }
129+
130+
.. code-block:: php
131+
132+
// app/config/config.php
133+
$loader->import('parameters.xml');
123134
124-
# app/config/config.yml
125-
imports:
126-
- { resource: parameters.xml }
127135
128136
Miscellaneous Configuration
129137
---------------------------

cookbook/configuration/override_dir_structure.rst

+28-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ directory structure is:
2323
app.php
2424
...
2525
26+
.. _override-cache-dir:
27+
2628
Override the ``cache`` directory
2729
--------------------------------
2830

@@ -53,6 +55,8 @@ the location of the cache directory to ``app/{environment}/cache``.
5355
its own cached config files, and so each needs its own directory to store
5456
those cache files.
5557

58+
.. _override-logs-dir:
59+
5660
Override the ``logs`` directory
5761
-------------------------------
5862

@@ -101,14 +105,33 @@ may need to modify the paths inside these files::
101105
If you use the AsseticBundle you need to configure this, so it can use
102106
the correct ``web`` directory:
103107

104-
.. code-block:: yaml
108+
.. configuration-block::
109+
110+
.. code-block:: yaml
105111
106-
# app/config/config.yml
112+
# app/config/config.yml
107113
108-
# ...
109-
assetic:
110114
# ...
111-
read_from: "%kernel.root_dir%/../../public_html"
115+
assetic:
116+
# ...
117+
read_from: "%kernel.root_dir%/../../public_html"
118+
119+
.. code-block:: xml
120+
121+
<!-- app/config/config.xml -->
122+
123+
<!-- ... -->
124+
<assetic:config read-from="%kernel.root_dir%/../../public_html" />
125+
126+
.. code-block:: php
127+
128+
// app/config/config.php
129+
130+
// ...
131+
$container->loadFromExtension('assetic', array(
132+
// ...
133+
'read_from' => '%kernel.root_dir%/../../public_html',
134+
));
112135
113136
Now you just need to dump the assets again and your application should
114137
work:

cookbook/doctrine/dbal.rst

+3-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To get started, configure the database connection parameters:
3838
3939
.. code-block:: xml
4040
41-
// app/config/config.xml
41+
<!-- app/config/config.xml -->
4242
<doctrine:config>
4343
<doctrine:dbal
4444
name="default"
@@ -64,9 +64,7 @@ To get started, configure the database connection parameters:
6464
For full DBAL configuration options, see :ref:`reference-dbal-configuration`.
6565

6666
You can then access the Doctrine DBAL connection by accessing the
67-
``database_connection`` service:
68-
69-
.. code-block:: php
67+
``database_connection`` service::
7068

7169
class UserController extends Controller
7270
{
@@ -186,4 +184,4 @@ mapping type:
186184
.. _`PDO`: http://www.php.net/pdo
187185
.. _`Doctrine`: http://www.doctrine-project.org
188186
.. _`DBAL Documentation`: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/index.html
189-
.. _`Custom Mapping Types`: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#custom-mapping-types
187+
.. _`Custom Mapping Types`: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#custom-mapping-types

0 commit comments

Comments
 (0)