Skip to content

Commit ba770f2

Browse files
committed
Merge branch 'collection_of_minor_fixes' of github.com:bicpi/symfony-docs into bicpi-collection_of_minor_fixes
Conflicts: book/translation.rst cookbook/assetic/uglifyjs.rst cookbook/bundles/remove.rst cookbook/form/form_customization.rst
2 parents f14ef95 + 2300a74 commit ba770f2

35 files changed

+140
-87
lines changed

book/translation.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,52 @@ the framework:
525525
originally, however, as of 2.1 this has been moved. This is because the
526526
locale is now set on the request instead of the session.
527527

528+
PHP Templates
529+
~~~~~~~~~~~~~
530+
531+
The translator service is accessible in PHP templates through the
532+
``translator`` helper:
533+
534+
.. code-block:: html+php
535+
536+
<?php echo $view['translator']->trans('Symfony2 is great') ?>
537+
538+
<?php echo $view['translator']->transChoice(
539+
'{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
540+
10,
541+
array('%count%' => 10)
542+
) ?>
543+
544+
Forcing the Translator Locale
545+
-----------------------------
546+
547+
When translating a message, Symfony2 uses the locale from the current request
548+
or the ``fallback`` locale if necessary. You can also manually specify the
549+
locale to use for translation::
550+
551+
$this->get('translator')->trans(
552+
'Symfony2 is great',
553+
array(),
554+
'messages',
555+
'fr_FR'
556+
);
557+
558+
$this->get('translator')->transChoice(
559+
'{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
560+
10,
561+
array('%count%' => 10),
562+
'messages',
563+
'fr_FR'
564+
);
565+
566+
Translating Database Content
567+
----------------------------
568+
569+
The translation of database content should be handled by Doctrine through
570+
the `Translatable Extension`_. For more information, see the documentation
571+
for that library.
572+
>>>>>>> 2300a74000deafb340921eec2310a399be8d5a25
573+
528574
.. _book-translation-constraint-messages:
529575

530576
Translating Constraint Messages

cookbook/assetic/apply_to_option.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ work as the regular JavaScript files will not survive the CoffeeScript compilati
119119

120120
This problem can be avoided by using the ``apply_to`` option in the config,
121121
which allows you to specify that a filter should always be applied to particular
122-
file extensions. In this case you can specify that the Coffee filter is
122+
file extensions. In this case you can specify that the ``coffee`` filter is
123123
applied to all ``.coffee`` files:
124124

125125
.. configuration-block::

cookbook/assetic/asset_management.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ in your source, you'll likely just see something like this:
352352

353353
.. code-block:: html
354354

355-
<script src="/app_dev.php/js/abcd123.js"></script>
355+
<script src="/js/abcd123.js"></script>
356356

357357
Moreover, that file does **not** actually exist, nor is it dynamically rendered
358358
by Symfony (as the asset files are in the ``dev`` environment). This is on

cookbook/assetic/uglifyjs.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ your JavaScripts:
104104
It should output a folder on your system, inside which you should find
105105
the UglifyJS executable.
106106

107-
If you installed UglifyJS locally, you can find the bin folder inside
107+
If you installed UglifyJS locally, you can find the ``bin`` folder inside
108108
the ``node_modules`` folder. It's called ``.bin`` in this case.
109109

110110
You now have access to the ``uglifyjs2`` filter in your application.
@@ -175,7 +175,7 @@ and :ref:`dump your assetic assets <cookbook-asetic-dump-prod>`.
175175
.. tip::
176176

177177
Instead of adding the filter to the asset tags, you can also globally
178-
enable it by adding the apply-to attribute to the filter configuration, for
178+
enable it by adding the ``apply_to`` attribute to the filter configuration, for
179179
example in the ``uglifyjs2`` filter ``apply_to: "\.js$"``. To only have
180180
the filter applied in production, add this to the ``config_prod`` file
181181
rather than the common config file. For details on applying filters by

cookbook/assetic/yuicompressor.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ apply this filter when debug mode is off.
156156
.. tip::
157157

158158
Instead of adding the filter to the asset tags, you can also globally
159-
enable it by adding the apply-to attribute to the filter configuration, for
160-
example in the yui_js filter ``apply_to: "\.js$"``. To only have the filter
161-
applied in production, add this to the config_prod file rather than the
159+
enable it by adding the ``apply_to`` attribute to the filter configuration, for
160+
example in the ``yui_js`` filter ``apply_to: "\.js$"``. To only have the filter
161+
applied in production, add this to the ``config_prod`` file rather than the
162162
common config file. For details on applying filters by file extension,
163163
see :ref:`cookbook-assetic-apply-to`.
164164

cookbook/bundles/best_practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class name.
5656
.. note::
5757

5858
Symfony2 core Bundles do not prefix the Bundle class with ``Symfony``
59-
and always add a ``Bundle`` subnamespace; for example:
59+
and always add a ``Bundle`` sub-namespace; for example:
6060
:class:`Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle`.
6161

6262
Each bundle has an alias, which is the lower-cased short version of the bundle

cookbook/bundles/extension.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The second method has several specific advantages:
7070
* Much more powerful than simply defining parameters: a specific option value
7171
might trigger the creation of many service definitions;
7272

73-
* Ability to have configuration hierarchy
73+
* Ability to have configuration hierarchy;
7474

7575
* Smart merging when several configuration files (e.g. ``config_dev.yml``
7676
and ``config.yml``) override each other's configuration;

cookbook/bundles/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ current development version of FOSUserBundle is ``"friendsofsymfony/user-bundle"
4141
Now you can add the bundle to your ``composer.json`` file and update the
4242
dependencies. You can do this manually:
4343

44-
1. **Add it to the composer.json file:**
44+
1. **Add it to the ``composer.json`` file:**
4545

4646
.. code-block:: json
4747
@@ -137,7 +137,7 @@ Other Setup
137137
-----------
138138

139139
At this point, check the ``README`` file of your brand new bundle to see
140-
what do to next.
140+
what to do next.
141141

142142
.. _their documentation: http://getcomposer.org/doc/00-intro.md
143143
.. _Packagist: https://packagist.org

cookbook/bundles/remove.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ and ``_demo``. Remove all three of these entries.
5757

5858
Some bundles contain configuration in one of the ``app/config/config*.yml``
5959
files. Be sure to remove the related configuration from these files. You can
60-
quickly spot bundle configuration by looking at a ``acme_demo`` (or whatever
60+
quickly spot bundle configuration by looking for a ``acme_demo`` (or whatever
6161
the name of the bundle is, e.g. ``fos_user`` for the FOSUserBundle) string in
6262
the configuration files.
6363

cookbook/configuration/apache_router.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ Symfony2 to use the ``ApacheUrlMatcher`` instead of the default one:
4545

4646
Note that :class:`Symfony\\Component\\Routing\\Matcher\\ApacheUrlMatcher`
4747
extends :class:`Symfony\\Component\\Routing\\Matcher\\UrlMatcher` so even
48-
if you don't regenerate the url_rewrite rules, everything will work (because
48+
if you don't regenerate the mod_rewrite rules, everything will work (because
4949
at the end of ``ApacheUrlMatcher::match()`` a call to ``parent::match()``
5050
is done).
5151

5252
Generating mod_rewrite rules
5353
----------------------------
5454

55-
To test that it's working, let's create a very basic route for demo bundle:
55+
To test that it's working, let's create a very basic route for the AcmeDemoBundle:
5656

5757
.. configuration-block::
5858

@@ -77,7 +77,7 @@ To test that it's working, let's create a very basic route for demo bundle:
7777
'_controller' => 'AcmeDemoBundle:Demo:hello',
7878
)));
7979
80-
Now generate **url_rewrite** rules:
80+
Now generate the mod_rewrite rules:
8181

8282
.. code-block:: bash
8383
@@ -95,7 +95,7 @@ Which should roughly output the following:
9595
RewriteCond %{REQUEST_URI} ^/hello/([^/]+?)$
9696
RewriteRule .* app.php [QSA,L,E=_ROUTING__route:hello,E=_ROUTING_name:%1,E=_ROUTING__controller:AcmeDemoBundle\:Demo\:hello]
9797
98-
You can now rewrite `web/.htaccess` to use the new rules, so with this example
98+
You can now rewrite ``web/.htaccess`` to use the new rules, so with this example
9999
it should look like this:
100100

101101
.. code-block:: apache
@@ -114,10 +114,10 @@ it should look like this:
114114
115115
.. note::
116116

117-
Procedure above should be done each time you add/change a route if you want to take full advantage of this setup
117+
The procedure above should be done each time you add/change a route if you want to take full advantage of this setup.
118118

119119
That's it!
120-
You're now all set to use Apache Route rules.
120+
You're now all set to use Apache routes.
121121

122122
Additional tweaks
123123
-----------------

cookbook/configuration/environments.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ includes the following:
331331
* ``appDevDebugProjectContainer.php`` - the cached "service container" that
332332
represents the cached application configuration;
333333

334-
* ``appdevUrlGenerator.php`` - the PHP class generated from the routing
334+
* ``appDevUrlGenerator.php`` - the PHP class generated from the routing
335335
configuration and used when generating URLs;
336336

337-
* ``appdevUrlMatcher.php`` - the PHP class used for route matching - look
337+
* ``appDevUrlMatcher.php`` - the PHP class used for route matching - look
338338
here to see the compiled regular expression logic used to match incoming
339339
URLs to different routes;
340340

cookbook/configuration/external_parameters.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ in the container. The following imports a file named ``parameters.php``.
133133
closure resources are all supported by the ``imports`` directive.
134134

135135
In ``parameters.php``, tell the service container the parameters that you wish
136-
to set. This is useful when important configuration is in a nonstandard
137-
format. The example below includes a Drupal database's configuration in
136+
to set. This is useful when important configuration is in a non-standard
137+
format. The example below includes a Drupal database configuration in
138138
the Symfony service container.
139139

140140
.. code-block:: php

cookbook/configuration/front_controllers_and_kernel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ independently (for example, the admin UI, the frontend UI and database migration
139139
The Environments
140140
----------------
141141

142-
We just mentioned another method the ``AppKernel`` has to implement -
142+
As just mentioned, the ``AppKernel`` has to implement another method -
143143
:method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerContainerConfiguration`.
144144
This method is responsible for loading the application's
145145
configuration from the right *environment*.

cookbook/configuration/pdo_session_storage.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ To use it, you just need to change some parameters in ``config.yml`` (or the
1515
configuration format of your choice):
1616

1717
.. versionadded:: 2.1
18-
In Symfony2.1 the class and namespace are slightly modified. You can now
18+
In Symfony 2.1 the class and namespace are slightly modified. You can now
1919
find the session storage classes in the `Session\\Storage` namespace:
2020
``Symfony\Component\HttpFoundation\Session\Storage``. Also
21-
note that in Symfony2.1 you should configure ``handler_id`` not ``storage_id`` like in Symfony2.0.
21+
note that in Symfony 2.1 you should configure ``handler_id`` not ``storage_id`` like in Symfony 2.0.
2222
Below, you'll notice that ``%session.storage.options%`` is not used anymore.
2323

2424
.. configuration-block::
@@ -134,7 +134,7 @@ database for the session data.
134134

135135
But if you'd like to store the session data in the same database as the rest
136136
of your project's data, you can use the connection settings from the
137-
parameter.ini by referencing the database-related parameters defined there:
137+
``parameters.yml`` file by referencing the database-related parameters defined there:
138138

139139
.. configuration-block::
140140

cookbook/configuration/web_server_configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ are:
4040

4141
For performance reasons, you will probably want to set
4242
``AllowOverride None`` and implement the rewrite rules in the ``web/.htaccess``
43-
into the virtualhost config.
43+
into the ``VirtualHost`` config.
4444

4545
If you are using **php-cgi**, Apache does not pass HTTP basic username and
4646
password to PHP by default. To work around this limitation, you should use the
@@ -53,7 +53,7 @@ following configuration snippet:
5353
.. caution::
5454

5555
In Apache 2.4, ``Order allow,deny`` has been replaced by ``Require all granted``,
56-
and hence you need to modify your Directory permission settings as follows:
56+
and hence you need to modify your ``Directory`` permission settings as follows:
5757

5858
.. code-block:: apache
5959

cookbook/console/console_command.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ How to create a Console Command
55
===============================
66

77
The Console page of the Components section (:doc:`/components/console/introduction`) covers
8-
how to create a Console command. This cookbook article covers the differences
9-
when creating Console commands within the Symfony2 framework.
8+
how to create a console command. This cookbook article covers the differences
9+
when creating console commands within the Symfony2 framework.
1010

1111
Automatically Registering Commands
1212
----------------------------------

cookbook/console/logging.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ method, where exception handling should happen:
184184
}
185185
186186
In the code above, you disable exception catching so the parent ``run`` method
187-
will throw all exceptions. When an exception is caught, you simple log it by
187+
will throw all exceptions. When an exception is caught, you simply log it by
188188
accessing the ``logger`` service from the service container and then handle
189189
the rest of the logic in the same way that the parent ``run`` method does
190190
(specifically, since the parent :method:`run <Symfony\\Bundle\\FrameworkBundle\\Console\\Application::run>`
191191
method will not handle exceptions rendering and status code handling when
192192
``catchExceptions`` is set to false, it has to be done in the overridden
193193
method).
194194

195-
For the extended Application class to work properly with in console shell mode,
195+
For the extended ``Application`` class to work properly with in console shell mode,
196196
you have to do a small trick to intercept the ``autoExit`` setter and store the
197197
setting in a different property, since the parent property is private.
198198

cookbook/console/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ stack framework, some additional global options are available as well.
1111
By default, console commands run in the ``dev`` environment and you may want
1212
to change this for some commands. For example, you may want to run some commands
1313
in the ``prod`` environment for performance reasons. Also, the result of some commands
14-
will be different depending on the environment. for example, the ``cache:clear``
14+
will be different depending on the environment. For example, the ``cache:clear``
1515
command will clear and warm the cache for the specified environment only. To
1616
clear and warm the ``prod`` cache you need to run:
1717

cookbook/email/dev_environment.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ Instead, you can set the ``intercept_redirects`` option to ``true`` in the
136136
``config_dev.yml`` file, which will cause the redirect to stop and allow
137137
you to open the report with details of the sent emails.
138138

139-
.. tip::
140-
141-
Alternatively, you can open the profiler after the redirect and search
142-
by the submit URL used on previous request (e.g. ``/contact/handle``).
143-
The profiler's search feature allows you to load the profiler information
144-
for any past requests.
145-
146139
.. configuration-block::
147140

148141
.. code-block:: yaml
@@ -171,3 +164,10 @@ you to open the report with details of the sent emails.
171164
$container->loadFromExtension('web_profiler', array(
172165
'intercept_redirects' => 'true',
173166
));
167+
168+
.. tip::
169+
170+
Alternatively, you can open the profiler after the redirect and search
171+
by the submit URL used on the previous request (e.g. ``/contact/handle``).
172+
The profiler's search feature allows you to load the profiler information
173+
for any past requests.

cookbook/form/create_custom_field_type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Defining the Field Type
1616

1717
In order to create the custom field type, first you have to create the class
1818
representing the field. In this situation the class holding the field type
19-
will be called `GenderType` and the file will be stored in the default location
19+
will be called ``GenderType`` and the file will be stored in the default location
2020
for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extends
2121
:class:`Symfony\\Component\\Form\\AbstractType`::
2222

cookbook/form/create_form_type_extension.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ database)::
178178
Your form type extension class will need to do two things in order to extend
179179
the ``file`` form type:
180180

181-
#. Override the ``setDefaultOptions`` method in order to add an image_path
181+
#. Override the ``setDefaultOptions`` method in order to add an ``image_path``
182182
option;
183183
#. Override the ``buildForm`` and ``buildView`` methods in order to pass the image
184184
URL to the view.

cookbook/form/data_transformers.rst

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ This is where Data Transformers come into play.
2020
Creating the Transformer
2121
------------------------
2222

23-
First, create an `IssueToNumberTransformer` class - this class will be responsible
24-
for converting to and from the issue number and the Issue object::
23+
First, create an ``IssueToNumberTransformer`` class - this class will be responsible
24+
for converting to and from the issue number and the ``Issue`` object::
2525

2626
// src/Acme/TaskBundle/Form/DataTransformer/IssueToNumberTransformer.php
2727
namespace Acme\TaskBundle\Form\DataTransformer;
@@ -129,17 +129,16 @@ issue field in some form.
129129

130130
public function setDefaultOptions(OptionsResolverInterface $resolver)
131131
{
132-
$resolver->setDefaults(array(
133-
'data_class' => 'Acme\TaskBundle\Entity\Task',
134-
));
135-
136-
$resolver->setRequired(array(
137-
'em',
138-
));
139-
140-
$resolver->setAllowedTypes(array(
141-
'em' => 'Doctrine\Common\Persistence\ObjectManager',
142-
));
132+
$resolver
133+
->setDefaults(array(
134+
'data_class' => 'Acme\TaskBundle\Entity\Task',
135+
))
136+
->setRequired(array(
137+
'em',
138+
))
139+
->setAllowedTypes(array(
140+
'em' => 'Doctrine\Common\Persistence\ObjectManager',
141+
));
143142

144143
// ...
145144
}
@@ -239,7 +238,7 @@ In the above example, you applied the transformer to a normal ``text`` field.
239238
This was easy, but has two downsides:
240239

241240
1) You need to always remember to apply the transformer whenever you're adding
242-
a field for issue numbers
241+
a field for issue numbers.
243242

244243
2) You need to worry about passing in the ``em`` option whenever you're creating
245244
a form that uses the transformer.

0 commit comments

Comments
 (0)