Skip to content

Commit 38bbca1

Browse files
committed
Merge branch '2.2'
2 parents 6b4794c + 2f01d10 commit 38bbca1

Some content is hidden

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

41 files changed

+984
-127
lines changed

book/controller.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,14 @@ working with forms, for example::
332332
.. index::
333333
single: Controller; Base controller class
334334

335+
Creating Static Pages
336+
---------------------
337+
338+
You can create a static page without even creating a controller (only a route
339+
and template are needed).
340+
341+
Use it! See :doc:`/cookbook/templating/render_without_controller`.
342+
335343
The Base Controller Class
336344
-------------------------
337345

book/doctrine.rst

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -142,44 +142,43 @@ for you:
142142
collation-server = utf8_general_ci
143143
character-set-server = utf8
144144
145-
Using SQLite
146-
~~~~~~~~~~~~
145+
.. note::
147146

148-
If you want to use SQLite as your database, you need to set the path
149-
where your database file should be stored:
147+
If you want to use SQLite as your database, you need to set the path
148+
where your database file should be stored:
150149

151-
.. configuration-block::
150+
.. configuration-block::
152151

153-
.. code-block:: yaml
152+
.. code-block:: yaml
154153
155-
# app/config/config.yml
156-
doctrine:
157-
dbal:
158-
driver: pdo_sqlite
159-
path: "%kernel.root_dir%/sqlite.db"
160-
charset: UTF8
154+
# app/config/config.yml
155+
doctrine:
156+
dbal:
157+
driver: pdo_sqlite
158+
path: "%kernel.root_dir%/sqlite.db"
159+
charset: UTF8
161160
162-
.. code-block:: xml
161+
.. code-block:: xml
163162
164-
<!-- app/config/config.xml -->
165-
<doctrine:config
166-
driver="pdo_sqlite"
167-
path="%kernel.root_dir%/sqlite.db"
168-
charset="UTF-8"
169-
>
170-
<!-- ... -->
171-
</doctrine:config>
172-
173-
.. code-block:: php
174-
175-
// app/config/config.php
176-
$container->loadFromExtension('doctrine', array(
177-
'dbal' => array(
178-
'driver' => 'pdo_sqlite',
179-
'path' => '%kernel.root_dir%/sqlite.db',
180-
'charset' => 'UTF-8',
181-
),
182-
));
163+
<!-- app/config/config.xml -->
164+
<doctrine:config
165+
driver="pdo_sqlite"
166+
path="%kernel.root_dir%/sqlite.db"
167+
charset="UTF-8"
168+
>
169+
<!-- ... -->
170+
</doctrine:config>
171+
172+
.. code-block:: php
173+
174+
// app/config/config.php
175+
$container->loadFromExtension('doctrine', array(
176+
'dbal' => array(
177+
'driver' => 'pdo_sqlite',
178+
'path' => '%kernel.root_dir%/sqlite.db',
179+
'charset' => 'UTF-8',
180+
),
181+
));
183182
184183
Creating an Entity Class
185184
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1313,7 +1312,7 @@ the current date, only when the entity is first persisted (i.e. inserted):
13131312
type: entity
13141313
# ...
13151314
lifecycleCallbacks:
1316-
prePersist: [ setCreatedValue ]
1315+
prePersist: [setCreatedValue]
13171316
13181317
.. code-block:: xml
13191318

book/installation.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,10 @@ Symfony2 should welcome and congratulate you for your hard work so far!
294294
this is not required for development it is recommended at the time your
295295
application goes into production as all system and configuration files
296296
become inaccessible to clients then. For information on configuring
297-
your specific web server document root, see the following
298-
documentation: `Apache`_ | `Nginx`_ .
297+
your specific web server document root, read
298+
:doc:`/cookbook/configuration/web_server_configuration`
299+
or consult the official documentation of your webserver:
300+
`Apache`_ | `Nginx`_ .
299301

300302
Beginning Development
301303
---------------------

book/page_creation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ the same basic and recommended directory structure:
439439

440440
* ``web/``: This is the web root directory and contains any publicly accessible files;
441441

442+
.. _the-web-directory:
443+
442444
The Web Directory
443445
~~~~~~~~~~~~~~~~~
444446

book/propel.rst

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Databases and Propel
77
One of the most common and challenging tasks for any application
88
involves persisting and reading information to and from a database. Symfony2
99
does not come integrated with any ORMs but the Propel integration is easy.
10-
To get started, read `Working With Symfony2`_.
10+
To install Propel, read `Working With Symfony2`_ on the Propel documentation.
1111

1212
A Simple Example: A Product
1313
---------------------------
@@ -28,7 +28,7 @@ Configuring the Database
2828
~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
Before you can start, you'll need to configure your database connection
31-
information. By convention, this information is usually configured in an
31+
information. By convention, this information is usually configured in an
3232
``app/config/parameters.yml`` file:
3333

3434
.. code-block:: yaml
@@ -48,14 +48,17 @@ information. By convention, this information is usually configured in an
4848
parameters defined in that file are referenced by the main configuration
4949
file when setting up Propel:
5050

51-
.. code-block:: yaml
51+
These parameters defined in ``parameters.yml`` can now be included in the
52+
configuration file (``config.yml``):
5253

53-
propel:
54-
dbal:
55-
driver: "%database_driver%"
56-
user: "%database_user%"
57-
password: "%database_password%"
58-
dsn: "%database_driver%:host=%database_host%;dbname=%database_name%;charset=%database_charset%"
54+
.. code-block:: yaml
55+
56+
propel:
57+
dbal:
58+
driver: "%database_driver%"
59+
user: "%database_user%"
60+
password: "%database_password%"
61+
dsn: "%database_driver%:host=%database_host%;dbname=%database_name%;charset=%database_charset%"
5962
6063
Now that Propel knows about your database, Symfony2 can create the database for
6164
you:
@@ -88,12 +91,28 @@ of your ``AcmeStoreBundle``:
8891
.. code-block:: xml
8992
9093
<?xml version="1.0" encoding="UTF-8"?>
91-
<database name="default" namespace="Acme\StoreBundle\Model" defaultIdMethod="native">
94+
<database name="default"
95+
namespace="Acme\StoreBundle\Model"
96+
defaultIdMethod="native"
97+
>
9298
<table name="product">
93-
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
94-
<column name="name" type="varchar" primaryString="true" size="100" />
95-
<column name="price" type="decimal" />
96-
<column name="description" type="longvarchar" />
99+
<column name="id"
100+
type="integer"
101+
required="true"
102+
primaryKey="true"
103+
autoIncrement="true"
104+
/>
105+
<column name="name"
106+
type="varchar"
107+
primaryString="true"
108+
size="100"
109+
/>
110+
<column name="price"
111+
type="decimal"
112+
/>
113+
<column name="description"
114+
type="longvarchar"
115+
/>
97116
</table>
98117
</database>
99118
@@ -217,15 +236,15 @@ have a route that maps a product id to an update action in a controller::
217236

218237
Updating an object involves just three steps:
219238

220-
#. fetching the object from Propel;
221-
#. modifying the object;
222-
#. saving it.
239+
#. fetching the object from Propel (line 6 - 13);
240+
#. modifying the object (line 15);
241+
#. saving it (line 16).
223242

224243
Deleting an Object
225244
~~~~~~~~~~~~~~~~~~
226245

227-
Deleting an object is very similar, but requires a call to the ``delete()``
228-
method on the object::
246+
Deleting an object is very similar to updating, but requires a call to the
247+
``delete()`` method on the object::
229248

230249
$product->delete();
231250

book/routing.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ a slash. URLs matching this route might look like:
770770

771771
* ``/articles/en/2010/my-post``
772772
* ``/articles/fr/2010/my-post.rss``
773+
* ``/articles/en/2013/my-latest-post.html``
773774

774775
.. _book-routing-format-param:
775776

@@ -1062,7 +1063,7 @@ the command by running the following from the root of your project.
10621063
10631064
$ php app/console router:debug
10641065
1065-
The command will print a helpful list of *all* the configured routes in
1066+
This command will print a helpful list of *all* the configured routes in
10661067
your application:
10671068

10681069
.. code-block:: text
@@ -1081,16 +1082,18 @@ the route name after the command:
10811082
10821083
$ php app/console router:debug article_show
10831084
1084-
.. versionadded:: 2.1
1085-
The ``router:match`` command was added in Symfony 2.1
1086-
1087-
You can check which, if any, route matches a path with the ``router:match``
1088-
console command:
1085+
Likewise, if you want to test whether a URL matches a given route, you can
1086+
use the ``router:match`` console command:
10891087

10901088
.. code-block:: bash
10911089
1092-
$ php app/console router:match /articles/en/2012/article.rss
1093-
Route "article_show" matches
1090+
$ php app/console router:match /blog/my-latest-post
1091+
1092+
This command will print which route the URL matches.
1093+
1094+
.. code-block:: text
1095+
1096+
Route "blog_show" matches
10941097
10951098
.. index::
10961099
single: Routing; Generating URLs

book/service_container.rst

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ straightforward. Parameters make defining services more organized and flexible:
192192
services:
193193
my_mailer:
194194
class: "%my_mailer.class%"
195-
arguments: [%my_mailer.transport%]
195+
arguments: ["%my_mailer.transport%"]
196196
197197
.. code-block:: xml
198198
@@ -244,6 +244,23 @@ looks up the value of each parameter and uses it in the service definition.
244244
# This will be parsed as string "@securepass"
245245
mailer_password: "@@securepass"
246246
247+
.. note::
248+
249+
The percent sign inside a parameter or argument, as part of the string, must
250+
be escaped with another percent sign:
251+
252+
.. code-block:: xml
253+
254+
<argument type="string">http://symfony.com/?foo=%%s&bar=%%d</argument>
255+
256+
.. caution::
257+
258+
You may receive a
259+
:class:`Symfony\\Component\\DependencyInjection\\Exception\\ScopeWideningInjectionException`
260+
when passing the ``request`` service as an argument. To understand this
261+
problem better and learn how to solve it, refer to the cookbook article
262+
:doc:`/cookbook/service_container/scopes`.
263+
247264
The purpose of parameters is to feed information into services. Of course
248265
there was nothing wrong with defining the service without using any parameters.
249266
Parameters, however, have several advantages:
@@ -318,7 +335,7 @@ directories don't exist, create them.
318335
services:
319336
my_mailer:
320337
class: "%my_mailer.class%"
321-
arguments: [%my_mailer.transport%]
338+
arguments: ["%my_mailer.transport%"]
322339
323340
.. code-block:: xml
324341
@@ -358,7 +375,7 @@ configuration.
358375
359376
# app/config/config.yml
360377
imports:
361-
- { resource: @AcmeHelloBundle/Resources/config/services.yml }
378+
- { resource: "@AcmeHelloBundle/Resources/config/services.yml" }
362379
363380
.. code-block:: xml
364381
@@ -557,7 +574,7 @@ the service container gives you a much more appealing option:
557574
# ...
558575
newsletter_manager:
559576
class: "%newsletter_manager.class%"
560-
arguments: [@my_mailer]
577+
arguments: ["@my_mailer"]
561578
562579
.. code-block:: xml
563580
@@ -648,7 +665,7 @@ Injecting the dependency by the setter method just needs a change of syntax:
648665
newsletter_manager:
649666
class: "%newsletter_manager.class%"
650667
calls:
651-
- [ setMailer, [ @my_mailer ] ]
668+
- [setMailer, ["@my_mailer"]]
652669
653670
.. code-block:: xml
654671
@@ -715,7 +732,7 @@ it exists and do nothing if it doesn't:
715732
services:
716733
newsletter_manager:
717734
class: "%newsletter_manager.class%"
718-
arguments: [@?my_mailer]
735+
arguments: ["@?my_mailer"]
719736
720737
.. code-block:: xml
721738
@@ -820,7 +837,7 @@ Configuring the service container is easy:
820837
services:
821838
newsletter_manager:
822839
class: "%newsletter_manager.class%"
823-
arguments: [@mailer, @templating]
840+
arguments: ["@mailer", "@templating"]
824841
825842
.. code-block:: xml
826843
@@ -846,8 +863,8 @@ the framework.
846863

847864
.. tip::
848865

849-
Be sure that ``swiftmailer`` entry appears in your application
850-
configuration. As you mentioned in :ref:`service-container-extension-configuration`,
866+
Be sure that the ``swiftmailer`` entry appears in your application
867+
configuration. As was mentioned in :ref:`service-container-extension-configuration`,
851868
the ``swiftmailer`` key invokes the service extension from the
852869
``SwiftmailerBundle``, which registers the ``mailer`` service.
853870

book/testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ or perform more complex requests::
345345
// Directly submit a form (but using the Crawler is easier!)
346346
$client->request('POST', '/submit', array('name' => 'Fabien'));
347347

348-
// Submit a raw JSON string in the requst body
348+
// Submit a raw JSON string in the request body
349349
$client->request(
350350
'POST',
351351
'/submit',

components/dependency_injection/factories.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ in the previous example takes the ``templating`` service as an argument:
162162
factory_service: newsletter_factory
163163
factory_method: get
164164
arguments:
165-
- @templating
165+
- "@templating"
166166
167167
.. code-block:: xml
168168

components/dependency_injection/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ config files:
236236
services:
237237
mailer:
238238
class: Mailer
239-
arguments: [%mailer.transport%]
239+
arguments: ["%mailer.transport%"]
240240
newsletter_manager:
241241
class: NewsletterManager
242242
calls:
243-
- [ setMailer, [ @mailer ] ]
243+
- [setMailer, ["@mailer"]]
244244
245245
.. code-block:: xml
246246

0 commit comments

Comments
 (0)