Skip to content

Commit 73ad370

Browse files
committed
Merge branch '3.3' into 3.4
* 3.3: Updated the console binary path Added minor clarification about what StudlyCaps is Update best_practices.rst add missing twig dump construct Removed the reference to specific Symfony files do not render the description as a blockquote Added a new section "Extracting Translation Contents and Updating Cat… Moved the note before the label PathPackage and asset with absolute path Path package in context aware moved the tips to an include fragment file added a tip to register annotations namespaces
2 parents 2a11e79 + e228bf6 commit 73ad370

File tree

9 files changed

+80
-21
lines changed

9 files changed

+80
-21
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. note::
2+
3+
In order to use the annotation loader, you should have installed the
4+
``doctrine/annotations`` and ``doctrine/cache`` packages with Composer.
5+
6+
.. tip::
7+
8+
Annotation classes aren't loaded automatically, so you must load them
9+
using a class loader like this::
10+
11+
      use Composer\Autoload\ClassLoader;
12+
use Doctrine\Common\Annotations\AnnotationRegistry;
13+
14+
/** @var ClassLoader $loader */
15+
$loader = require __DIR__.'/../vendor/autoload.php';
16+
17+
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
18+
19+
return $loader;

bundles/best_practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ A namespace becomes a bundle as soon as you add a bundle class to it. The
3737
bundle class name must follow these simple rules:
3838

3939
* Use only alphanumeric characters and underscores;
40-
* Use a CamelCased name;
40+
* Use a StudlyCaps name (i.e. camelCase with the first letter uppercased);
4141
* Use a descriptive and short name (no more than two words);
4242
* Prefix the name with the concatenation of the vendor (and optionally the
4343
category namespaces);

components/asset.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,13 @@ class can take into account the context of the current request::
204204
new StaticVersionStrategy('v1'),
205205
new RequestStackContext($requestStack)
206206
);
207-
208-
echo $package->getUrl('/logo.png');
207+
208+
echo $package->getUrl('logo.png');
209209
// result: /somewhere/static/images/logo.png?v1
210+
211+
// Both "base path" and "base url" are ignored when using absolute path for asset
212+
echo $package->getUrl('/logo.png');
213+
// result: /logo.png?v1
210214

211215
Now that the request context is set, the ``PathPackage`` will prepend the
212216
current request base URL. So, for example, if your entire site is hosted under
@@ -335,7 +339,7 @@ document inside a template::
335339
echo $packages->getUrl('/logo.png', 'img');
336340
// result: http://img.example.com/logo.png?v1
337341

338-
echo $packages->getUrl('/resume.pdf', 'doc');
342+
echo $packages->getUrl('resume.pdf', 'doc');
339343
// result: /somewhere/deep/for/documents/resume.pdf?v1
340344

341345
Learn more

components/routing.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ Last but not least there are
312312
route definitions from class annotations. The specific details are left
313313
out here.
314314

315+
.. include:: /_includes/_rewrite_rule_tip.rst.inc
316+
315317
The all-in-one Router
316318
~~~~~~~~~~~~~~~~~~~~~
317319

components/serializer.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ You are now able to serialize only attributes in the groups you want::
326326
);
327327
// $obj2 = MyObj(foo: 'foo', bar: 'bar')
328328

329+
.. include:: /_includes/_rewrite_rule_tip.rst.inc
330+
329331
.. _ignoring-attributes-when-serializing:
330332

331333
Selecting Specific Attributes

components/validator/resources.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ method. It takes an optional annotation reader instance, which defaults to
119119
To disable the annotation loader after it was enabled, call
120120
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`.
121121

122-
.. note::
123-
124-
In order to use the annotation loader, you should have installed the
125-
``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_.
122+
.. include:: /_includes/_rewrite_rule_tip.rst.inc
126123

127124
Using Multiple Loaders
128125
----------------------

templating/debug.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,25 @@ for example, inside your controller::
3333
The output of the ``dump()`` function is then rendered in the web developer
3434
toolbar.
3535

36-
The same mechanism can be used in Twig templates thanks to ``dump()`` function:
36+
In a Twig template, you can use the ``dump`` utility as a function or a tag:
37+
38+
* ``{% dump foo.bar %}`` is the way to go when the original template output
39+
shall not be modified: variables are not dumped inline, but in the web
40+
debug toolbar;
41+
* on the contrary, ``{{ dump(foo.bar) }}`` dumps inline and thus may or not
42+
be suited to your use case (e.g. you shouldn't use it in an HTML
43+
attribute or a ``<script>`` tag).
3744

3845
.. code-block:: html+twig
3946

4047
{# app/Resources/views/article/recent_list.html.twig #}
41-
{{ dump(articles) }}
48+
{# the contents of this variable are sent to the Web Debug Toolbar #}
49+
{% dump articles %}
4250

4351
{% for article in articles %}
52+
{# the contents of this variable are display on the web page #}
53+
{{ dump(article) }}
54+
4455
<a href="/article/{{ article.slug }}">
4556
{{ article.title }}
4657
</a>

translation.rst

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,12 @@ of text (called a *message*), use the
107107
for example, that you're translating a simple message from inside a controller::
108108

109109
// ...
110-
use Symfony\Component\HttpFoundation\Response;
111110

112111
public function indexAction()
113112
{
114113
$translated = $this->get('translator')->trans('Symfony is great');
115114

116-
return new Response($translated);
115+
// ...
117116
}
118117

119118
.. _translation-resources:
@@ -185,13 +184,11 @@ Message Placeholders
185184

186185
Sometimes, a message containing a variable needs to be translated::
187186

188-
use Symfony\Component\HttpFoundation\Response;
189-
190187
public function indexAction($name)
191188
{
192189
$translated = $this->get('translator')->trans('Hello '.$name);
193190

194-
return new Response($translated);
191+
// ...
195192
}
196193

197194
However, creating a translation for this string is impossible since the translator
@@ -258,11 +255,11 @@ You can also specify the message domain and pass some additional variables:
258255

259256
.. code-block:: twig
260257
261-
{% trans with {'%name%': 'Fabien'} from "app" %}Hello %name%{% endtrans %}
258+
{% trans with {'%name%': 'Fabien'} from 'app' %}Hello %name%{% endtrans %}
262259
263-
{% trans with {'%name%': 'Fabien'} from "app" into "fr" %}Hello %name%{% endtrans %}
260+
{% trans with {'%name%': 'Fabien'} from 'app' into 'fr' %}Hello %name%{% endtrans %}
264261
265-
{% transchoice count with {'%name%': 'Fabien'} from "app" %}
262+
{% transchoice count with {'%name%': 'Fabien'} from 'app' %}
266263
{0} %name%, there are no apples|{1} %name%, there is one apple|]1,Inf[ %name%, there are %count% apples
267264
{% endtranschoice %}
268265
@@ -277,7 +274,7 @@ texts* and complex expressions:
277274
278275
{{ message|transchoice(5) }}
279276
280-
{{ message|trans({'%name%': 'Fabien'}, "app") }}
277+
{{ message|trans({'%name%': 'Fabien'}, 'app') }}
281278
282279
{{ message|transchoice(5, {'%name%': 'Fabien'}, 'app') }}
283280
@@ -308,7 +305,7 @@ texts* and complex expressions:
308305

309306
.. code-block:: twig
310307
311-
{% trans_default_domain "app" %}
308+
{% trans_default_domain 'app' %}
312309
313310
Note that this only influences the current template, not any "included"
314311
template (in order to avoid side effects).
@@ -329,6 +326,33 @@ The translator service is accessible in PHP templates through the
329326
array('%count%' => 10)
330327
) ?>
331328

329+
Extracting Translation Contents and Updating Catalogs Automatically
330+
-------------------------------------------------------------------
331+
332+
The most time-consuming tasks when translating an application is to extract all
333+
the template contents to be translated and to keep all the translation files in
334+
sync. Symfony includes a command called ``translation:update`` that helps you
335+
with these tasks:
336+
337+
.. code-block:: terminal
338+
339+
# updates the French translation file with the missing strings found in app/Resources/ templates
340+
$ ./bin/console translation:update --dump-messages --force fr
341+
342+
# updates the English translation file with the missing strings found in AppBundle
343+
$ ./bin/console translation:update --dump-messages --force en AppBundle
344+
345+
.. note::
346+
347+
If you want to see the missing translation strings without actually updating
348+
the translation files, remove the ``--force`` option from the command above.
349+
350+
.. tip::
351+
352+
If you need to extract translation strings from other sources, such as
353+
controllers, forms and flash messages, consider using the more advanced
354+
third-party `TranslationBundle`_.
355+
332356
.. _translation-resource-locations:
333357

334358
Translation Resource/File Names and Locations
@@ -513,3 +537,4 @@ Learn more
513537
.. _`ISO 639-1`: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
514538
.. _`Translatable Extension`: http://atlantic18.github.io/DoctrineExtensions/doc/translatable.html
515539
.. _`Translatable Behavior`: https://github.com/KnpLabs/DoctrineBehaviors
540+
.. _`TranslationBundle`: https://github.com/php-translation/symfony-bundle

workflow/usage.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ order:
231231
* ``workflow.[workflow name].enter.[place name]``
232232

233233
``workflow.entered``
234-
235234
Similar to ``workflow.enter``, except the marking store is updated before this
236235
event (making it a good place to flush data in Doctrine).
237236

0 commit comments

Comments
 (0)