8000 Merge remote-tracking branch 'upstream/master' · symfony/symfony-docs@fc7b1ff · GitHub
[go: up one dir, main page]

Skip to content

Commit fc7b1ff

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 39bf014 + 2b1dbee commit fc7b1ff

File tree

119 files changed

+1447
-744
lines changed

Some content is hidden

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

119 files changed

+1447
-744
lines changed

_build/redirection_map

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,5 @@
332332
/deployment/tools /deployment
333333
/install/bundles /setup/bundles
334334
/form /forms
335+
/testing/simulating_authentication /testing/http_authentication
336+
/components/dependency_injection/autowiring /service_container/autowiring
-12 KB
Loading

_images/security/anonymous_wdt.png

-1.9 KB
Loading
-3.56 KB
Loading

assetic/apply_to_option.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ In this case you can specify that the ``coffee`` filter is applied to all
163163
name="coffee"
164164
bin="/usr/bin/coffee"
165165
node="/usr/bin/node"
166-
apply_to="\.coffee$" />
167-
<assetic:node-paths>/usr/lib/node_modules/</assetic:node-path>
166+
apply-to="\.coffee$">
167+
<assetic:node-path>/usr/lib/node_modules/</assetic:node-path>
168+
</assetic:filter>
168169
</assetic:config>
169170
</container>
170171
@@ -174,10 +175,10 @@ In this case you can specify that the ``coffee`` filter is applied to all
174175
$container->loadFromExtension('assetic', array(
175176
'filters' => array(
176177
'coffee' => array(
177-
'bin' => '/usr/bin/coffee',
178-
'node' => '/usr/bin/node',
178+
'bin' => '/usr/bin/coffee',
179+
'node' => '/usr/bin/node',
179180
'node_paths' => array('/usr/lib/node_modules/'),
180-
'apply_to' => '\.coffee$',
181+
'apply_to' => '\.coffee$',
181182
),
182183
),
183184
));

assetic/asset_management.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ configuration under the ``assetic`` section. Read more in the
411411
),
412412
),
413413
),
414-
);
414+
));
415415
416416
After you have defined the named assets, you can reference them in your templates
417417
with the ``@named_asset`` notation:

assetic/jpeg_optimize.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ to ``true``:
113113
<assetic:filter
114114
name="jpegoptim"
115115
bin="path/to/jpegoptim"
116-
strip_all="true" />
116+
strip-all="true" />
117117
</assetic:config>
118118
</container>
119119
@@ -217,7 +217,7 @@ following configuration:
217217
name="jpegoptim"
218218
bin="path/to/jpegoptim" />
219219
<assetic:twig>
220-
<assetic:twig_function
220+
<assetic:function
221221
name="jpegoptim" />
222222
</assetic:twig>
223223
</assetic:config>
@@ -234,7 +234,6 @@ following configuration:
234234
),
235235
'twig' => array(
236236
'functions' => array('jpegoptim'),
237-
),
238237
),
239238
));
240239
@@ -277,7 +276,7 @@ file:
277276
name="jpegoptim"
278277
bin="path/to/jpegoptim" />
279278
<assetic:twig>
280-
<assetic:twig_function
279+
<assetic:function
281280
name="jpegoptim"
282281
output="images/*.jpg" />
283282
</assetic:twig>
@@ -296,7 +295,7 @@ file:
296295
'twig' => array(
297296
'functions' => array(
298297
'jpegoptim' => array(
299-
output => 'images/*.jpg'
298+
'output' => 'images/*.jpg',
300299
),
301300
),
302301
),

assetic/php.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ First, configure a new ``scssphp`` Assetic filter:
9999
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">
100100
101101
<assetic:config>
102-
<filter name="scssphp" formatter="Leafo\ScssPhp\Formatter\Compressed" />
102+
<assetic:filter name="scssphp" formatter="Leafo\ScssPhp\Formatter\Compressed" />
103103
<!-- ... -->
104104
</assetic:config>
105105
</container>
@@ -172,7 +172,7 @@ First, configure a new ``jsqueeze`` Assetic filter as follows:
172172
http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">
173173
174174
<assetic:config>
175-
<filter name="jsqueeze" />
175+
<assetic:filter name="jsqueeze" />
176176
<!-- ... -->
177177
</assetic:config>
178178
</container>

assetic/uglifyjs.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ can configure its location usi 10000 ng the ``node`` key:
170170
171171
// app/config/config.php
172172
$container->loadFromExtension('assetic', array(
173-
'node' => '/usr/bin/nodejs',
173+
'node' => '/usr/bin/nodejs',
174174
'uglifyjs2' => array(
175-
// the path to the uglifyjs executable
176-
'bin' => '/usr/local/bin/uglifyjs',
177-
),
175+
// the path to the uglifyjs executable
176+
'bin' => '/usr/local/bin/uglifyjs',
177+
),
178178
));
179179
180180
Minify your Assets

best_practices/security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ To enable the security voter in the application, define a new service:
335335
# app/config/services.yml
336336
services:
337337
# ...
338-
post_voter:
338+
app.post_voter:
339339
class: AppBundle\Security\PostVoter
340340
arguments: ['@security.access.decision_manager']
341341
public: false

bundles/configuration.rst

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ bundle configuration would look like:
8181
8282
<!-- app/config/config.xml -->
8383
<?xml version="1.0" ?>
84-
8584
<container xmlns="http://symfony.com/schema/dic/services"
85+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8686
xmlns:acme-social="http://example.org/schema/dic/acme_social"
8787
xsi:schemaLocation="http://symfony.com/schema/dic/services
8888
http://symfony.com/schema/dic/services/services-1.0.xsd">
@@ -218,18 +218,64 @@ This class can now be used in your ``load()`` method to merge configurations and
218218
force validation (e.g. if an additional option was passed, an exception will be
219219
thrown)::
220220

221+
// src/Acme/SocialBundle/DependencyInjection/AcmeSocialExtension.php
222+
221223
public function load(array $configs, ContainerBuilder $container)
222224
{
223225
$configuration = new Configuration();
224226

225227
$config = $this->processConfiguration($configuration, $configs);
226-
// ...
228+
229+
// you now have these 2 config keys
230+
// $config['twitter']['client_id'] and $config['twitter']['client_secret']
227231
}
228232

229233
The ``processConfiguration()`` method uses the configuration tree you've defined
230234
in the ``Configuration`` class to validate, normalize and merge all the
231235
configuration arrays together.
232236

237+
Now, you can use the ``$config`` variable to modify a service provided by your bundle.
238+
For example, imagine your bundle has the following example config:
239+
240+
.. code-block:: xml
241+
242+
<!-- src/Acme/SocialBundle/Resources/config/services.xml -->
243+
<?xml version="1.0" encoding="UTF-8" ?>
244+
<container xmlns="http://symfony.com/schema/dic/services"
245+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
246+
xsi:schemaLocation="http://symfony.com/schema/dic/services
247+
http://symfony.com/schema/dic/services/services-1.0.xsd">
248+
249+
<services>
250+
<service id="acme.social.twitter_client" class="Acme\SocialBundle\TwitterClient">
251+
<argument></argument> <!-- will be filled in with client_id dynamically -->
252+
<argument></argument> <!-- will be filled in with client_secret dynamically -->
253+
</service>
254+
</services>
255+
</container>
256+
257+
In your extension, you can load this and dynamically set its arguments::
258+
259+
// src/Acme/SocialBundle/DependencyInjection/AcmeSocialExtension.php
260+
// ...
261+
262+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
263+
< F41A span class="pl-c1"> use Symfony\Component\Config\FileLocator;
264+
265+
public function load(array $configs, ContainerBuilder $container)
266+
{
267+
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
268+
$loader->load('services.xml');
269+
270+
$configuration = new Configuration();
271+
$config = $this->processConfiguration($configuration, $configs);
272+
273+
$def = $container->getDefinition('acme.social.twitter_client');
274+
$def->replaceArgument(0, $config['twitter']['client_id']);
275+
$def->replaceArgument(1, $config['twitter']['client_secret']);
276+
}
277+
278+
233279
.. tip::
234280

235281
Instead of calling ``processConfiguration()`` in your extension each time you
@@ -253,9 +299,7 @@ configuration arrays together.
253299
}
254300

255301
This class uses the ``getConfiguration()`` method to get the Configuration
256-
instance. You should override it if your Configuration class is not called
257-
``Configuration`` or if it is not placed in the same namespace as the
258-
extension.
302+
instance.
259303

260304
.. sidebar:: Processing the Configuration yourself
261305

bundles/inheritance.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ The same goes for routing files and some other resources.
9393

9494
The overriding of resources only works when you refer to resources with
9595
the ``@FOSUserBundle/Resources/config/routing/security.xml`` method.
96-
If you refer to resources without using the ``@BundleName`` shortcut, they
97-
can't be overridden in this way.
96+
You need to use the ``@BundleName`` shortcut when referring to resources
97+
so they can be successfully overridden (except templates, which are
98+
overridden in a different way, as explained in :doc:`/templating/overriding`).
9899

99100
.. caution::
100101

bundles/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ version, include it as the second argument of the `composer require`_ command:
4848
B) Enable the Bundle
4949
--------------------
5050

51-
At this point, the bundle is installed in your Symfony project (in
51+
At this point, the bundle is installed in your Symfony project (e.g.
5252
``vendor/friendsofsymfony/``) and the autoloader recognizes its classes.
5353
The only thing you need to do now is register the bundle in ``AppKernel``::
5454

@@ -118,7 +118,7 @@ of the bundle's configuration:
118118
119119
The output will look like this:
120120

121-
.. code-block:: text
121+
.. code-block:: yaml
122122
123123
assetic:
124124
debug: '%kernel.debug%'

bundles/override.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Services & Configuration
3939

4040
If you want to modify service definitions of another bundle, you can use a compiler
4141
pass to change the class of the service or to modify method calls. In the following
42-
example, the implementing class for the ``original-service-id`` is changed to
42+
example, the implementing class for the ``original-service-id`` is changed to
4343
``Acme\DemoBundle\YourService``::
4444

4545
// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
@@ -72,16 +72,8 @@ associations. Learn more about this feature and its limitations in
7272
Forms
7373
-----
7474

75-
Form types are referred to by their fully-qualified class name::
76-
77-
$builder->add('name', CustomType::class);
78-
79-
This means that you cannot override this by creating a sub-class of ``CustomType``
80-
and registering it as a service and tagging it with ``form.type`` (you *could*
81-
do this in earlier version).
82-
83-
Instead, you should use a "form type extension" to modify the existing form type.
84-
For more information, see :doc:`/form/create_form_type_extension`.
75+
Existing form types can be modified defining
76+
:doc:`form type extensions </form/create_form_type_extension>`.
8577

8678
.. _override-validation:
8779

@@ -92,7 +84,7 @@ Symfony loads all validation configuration files from every bundle and
9284
combines them into one validation metadata tree. This means you are able to
9385
add new constraints to a property, but you cannot override them.
9486

95-
To override this, the 3rd party bundle needs to have configuration for
87+
To overcome this, the 3rd party bundle needs to have configuration for
9688
:doc:`validation groups </validation/groups>`. For instance, the FOSUserBundle
9789
has this configuration. To create your own validation, add the constraints
9890
to a new validation group:

bundles/prepend_extension.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
single: Configuration; Semantic
33
single: Bundle; Extension configuration
44

5-
How to Simplify Configuration of multiple Bundles
5+
How to Simplify Configuration of Multiple Bundles
66
=================================================
77

88
When building reusable and extensible applications, developers are often
@@ -12,9 +12,9 @@ users to choose to remove functionality they are not using. Creating multiple
1212
bundles has the drawback that configuration becomes more tedious and settings
1313
often need to be repeated for various bundles.
1414

15-
Using the below approach, it is possible to remove the disadvantage of the
16-
multiple bundle approach by enabling a single Extension to prepend the settings
17-
for any bundle. It can use the settings defined in the ``app/config/config.yml``
15+
It is possible to remove the disadvantage of the multiple bundle approach
16+
by enabling a single Extension to prepend the settings for any bundle.
17+
It can use the settings defined in the ``app/config/config.yml``
1818
to prepend settings just as if they had been written explicitly by
1919
the user in the application configuration.
2020

components/class_loader/cache_class_loader.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Cache a Class Loader
99
====================
1010

1111
The ``ApcClassLoader``, the ``WinCacheClassLoader`` and the ``XcacheClassLoader``
12-
are deprecated since Symfony 3.3. Use the ``--optimize`` and ``--apcu-autoloader``
13-
options instead when dumping the autoloader using the ``composer dump-autoload``
14-
command.
12+
are deprecated since Symfony 3.3. As an alternative, use any of the
13+
`class loading optimizations`_ provided by Composer.
14+
15+
.. _`class loading optimizations`: https://getcomposer.org/doc/articles/autoloader-optimization.md

components/console/events.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ C/C++ standard.::
8686
The ``ConsoleEvents::EXCEPTION`` Event
8787
--------------------------------------
8888

89+
.. versionadded:: 3.3
90+
The ``ConsoleEvents::EXCEPTION`` event was deprecated in Symfony 3.3. Use
91+
the ``ConsoleEvents::ERROR`` event instead.
92+
8993
**Typical Purposes**: Handle exceptions thrown during the execution of a
9094
command.
9195

@@ -113,6 +117,19 @@ Listeners receive a
113117
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
114118
});
115119

120+
The ``ConsoleEvents::ERROR`` Event
121+
----------------------------------
122+
123+
.. versionadded:: 3.3
124+
The ``ConsoleEvents::ERROR`` event was introduced in Symfony 3.3.
125+
126+
**Typical Purposes**: Handle exceptions thrown during the execution of a
127+
command.
128+
129+
This event is an improved version of the ``ConsoleEvents::EXCEPTION`` event,
130+
because it can handle every exception thrown during the execution of a command,
131+
including those triggered from event listeners.
132+
116133
The ``ConsoleEvents::TERMINATE`` Event
117134
--------------------------------------
118135

components/console/helpers/progressbar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ before displaying these messages, you must define your own custom format::
300300
$progressBar->setFormat('custom');
301301

302302
Now, use the ``setMessage()`` method to set the value of the ``%message%``
303-
placeholder before displaying the progress bar:
303+
placeholder before displaying the progress bar::
304304

305305
// ...
306306
$progressBar->setMessage('Start');

components/filesystem.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ endpoint for filesystem operations::
4949
mkdir
5050
~~~~~
5151

52-
:method:`Symfony\\Component\\Filesystem\\Filesystem::mkdir` creates a directory.
52+
:method:`Symfony\\Component\\Filesystem\\Filesystem::mkdir` creates a directory recursively.
5353
On POSIX filesystems, directories are created with a default mode value
5454
`0777`. You can use the second argument to set your own mode::
5555

components/http_foundation.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,23 @@ class, which can make this even easier::
562562

563563
use Symfony\Component\HttpFoundation\JsonResponse;
564564

565+
// if you know the data to send when creating the response
566+
$response = new JsonResponse(array('data' => 123));
567+
568+
// if you don't know the data to send when creating the response
565569
$response = new JsonResponse();
566-
$response->setData(array(
567-
'data' => 123
568-
));
570+
// ...
571+
$response->setData(array('data' => 123));
572+
573+
// if the data to send is already encoded in JSON
574+
$response = JsonResponse::fromJsonString('{ "data": 123 }');
575+
576+
.. versionadded:: 3.2
577+
The :method:`Symfony\\Component\\HttpFoundation\\JsonResponse::fromJsonString`
578+
method was added in Symfony 3.2.
569579

570-
This encodes your array of data to JSON and sets the ``Content-Type`` header
571-
to ``application/json``.
580+
The ``JsonResponse`` class sets the ``Content-Type`` header to
581+
``application/json`` and encodes your data to JSON when needed.
572582

573583
.. caution::
574584

0 commit comments

Comments
 (0)
0