Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cdf3708

Browse filesBrowse files
committed
Merge branch '5.0'
* 5.0: Minor fixes in configuration blocks
2 parents c4b9d0d + 182c51b commit cdf3708
Copy full SHA for cdf3708

13 files changed

+307
-87
lines changed

‎bundles/configuration.rst

Copy file name to clipboardExpand all lines: bundles/configuration.rst
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,9 @@ Assuming the XSD file is called ``hello-1.0.xsd``, the schema location will be
416416
<container xmlns="http://symfony.com/schema/dic/services"
417417
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
418418
xmlns:acme-hello="http://acme_company.com/schema/dic/hello"
419-
xsi:schemaLocation="http://acme_company.com/schema/dic/hello
419+
xsi:schemaLocation="http://symfony.com/schema/dic/services
420+
https://symfony.com/schema/dic/services/services-1.0.xsd
421+
http://acme_company.com/schema/dic/hello
420422
https://acme_company.com/schema/dic/hello/hello-1.0.xsd">
421423
422424
<acme-hello:config>

‎bundles/prepend_extension.rst

Copy file name to clipboardExpand all lines: bundles/prepend_extension.rst
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ registered and the ``entity_manager_name`` setting for ``acme_hello`` is set to
122122
xmlns:acme-something="http://example.org/schema/dic/acme_something"
123123
xmlns:acme-other="http://example.org/schema/dic/acme_other"
124124
xsi:schemaLocation="http://symfony.com/schema/dic/services
125-
https://symfony.com/schema/dic/services/services-1.0.xsd">
125+
https://symfony.com/schema/dic/services/services-1.0.xsd
126+
http://example.org/schema/dic/acme_something
127+
https://example.org/schema/dic/acme_something/acme_something-1.0.xsd
128+
http://example.org/schema/dic/acme_other
129+
https://example.org/schema/dic/acme_something/acme_other-1.0.xsd">
126130
127131
<acme-something:config use-acme-goodbye="false">
132+
<!-- ... -->
128133
<acme-something:entity-manager-name>non_default</acme-something:entity-manager-name>
129134
</acme-something:config>
130135

‎cache.rst

Copy file name to clipboardExpand all lines: cache.rst
+56-9Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
7171
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7272
xmlns:framework="http://symfony.com/schema/dic/symfony"
7373
xsi:schemaLocation="http://symfony.com/schema/dic/services
74-
https://symfony.com/schema/dic/services/services-1.0.xsd">
74+
https://symfony.com/schema/dic/services/services-1.0.xsd
75+
http://symfony.com/schema/dic/symfony
76+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7577
7678
<framework:config>
7779
<framework:cache app="cache.adapter.filesystem"
@@ -132,7 +134,9 @@ will create pool with service id of ``cache.[type]``
132134
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
133135
xmlns:framework="http://symfony.com/schema/dic/symfony"
134136
xsi:schemaLocation="http://symfony.com/schema/dic/services
135-
https://symfony.com/schema/dic/services/services-1.0.xsd">
137+
https://symfony.com/schema/dic/services/services-1.0.xsd
138+
http://symfony.com/schema/dic/symfony
139+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
136140
137141
<framework:config>
138142
<!--
@@ -142,6 +146,7 @@ will create pool with service id of ``cache.[type]``
142146
default_memcached_provider: Service: cache.memcached
143147
default_pdo_provider: Service: cache.pdo
144148
-->
149+
<!-- "directory" attribute is only used with cache.adapter.filesystem -->
145150
<framework:cache directory="%kernel.cache_dir%/pools"
146151
default_doctrine_provider="app.doctrine_cache"
147152
default_psr6_provider="app.my_psr6_service"
@@ -222,14 +227,31 @@ You can also create more customized pools:
222227
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
223228
xmlns:framework="http://symfony.com/schema/dic/symfony"
224229
xsi:schemaLocation="http://symfony.com/schema/dic/services
225-
https://symfony.com/schema/dic/services/services-1.0.xsd">
230+
https://symfony.com/schema/dic/services/services-1.0.xsd
231+
http://symfony.com/schema/dic/symfony
232+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
226233
227234
<framework:config>
228-
<framework:cache default_memcached_provider="memcached://localhost">
235+
<framework:cache default-memcached-provider="memcached://localhost">
236+
<!-- creates a "custom_thing.cache" service
237+
autowireable via "CacheInterface $customThingCache"
238+
uses the "app" cache configuration -->
229239
<framework:pool name="custom_thing.cache" adapter="cache.app"/>
240+
241+
<!-- creates a "my_cache_pool" service
242+
autowireable via "CacheInterface $myCachePool" -->
230243
<framework:pool name="my_cache_pool" adapter="cache.adapter.array"/>
244+
245+
<!-- uses the default_memcached_provider from above -->
231246
<framework:pool name="acme.cache" adapter="cache.adapter.memcached"/>
232-
<framework:pool name="foobar.cache" adapter="cache.adapter.memcached" provider="memcached://user:password@example.com"/>
247+
248+
<!-- control adapter's configuration -->
249+
<framework:pool name="foobar.cache" adapter="cache.adapter.memcached"
250+
provider="memcached://user:password@example.com"
251+
/>
252+
253+
<!-- uses the "foobar.cache" pool as its backend but controls
254+
the lifetime and (like all pools) has a separate cache namespace -->
233255
<framework:pool name="short_cache" adapter="foobar.cache" default-lifetime="60"/>
234256
</framework:cache>
235257
</framework:config>
@@ -242,19 +264,32 @@ You can also create more customized pools:
242264
'cache' => [
243265
'default_memcached_provider' => 'memcached://localhost',
244266
'pools' => [
267+
// creates a "custom_thing.cache" service
268+
// autowireable via "CacheInterface $customThingCache"
269+
// uses the "app" cache configuration
245270
'custom_thing.cache' => [
246271
'adapter' => 'cache.app',
247272
],
273+
274+
// creates a "my_cache_pool" service
275+
// autowireable via "CacheInterface $myCachePool"
248276
'my_cache_pool' => [
249277
'adapter' => 'cache.adapter.array',
250278
],
279+
280+
// uses the default_memcached_provider from above
251281
'acme.cache' => [
252282
'adapter' => 'cache.adapter.memcached',
253283
],
284+
285+
// control adapter's configuration
254286
'foobar.cache' => [
255287
'adapter' => 'cache.adapter.memcached',
256288
'provider' => 'memcached://user:password@example.com',
257289
],
290+
291+
// uses the "foobar.cache" pool as its backend but controls
292+
// the lifetime and (like all pools) has a separate cache namespace
258293
'short_cache' => [
259294
'adapter' => 'foobar.cache',
260295
'default_lifetime' => 60,
@@ -327,7 +362,9 @@ and use that when configuring the pool.
327362
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
328363
xmlns:framework="http://symfony.com/schema/dic/symfony"
329364
xsi:schemaLocation="http://symfony.com/schema/dic/services
330-
https://symfony.com/schema/dic/services/services-1.0.xsd">
365+
https://symfony.com/schema/dic/services/services-1.0.xsd
366+
http://symfony.com/schema/dic/symfony
367+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
331368
332369
<framework:config>
333370
<framework:cache>
@@ -337,6 +374,7 @@ and use that when configuring the pool.
337374
338375
<services>
339376
<service id="app.my_custom_redis_provider" class="\Redis">
377+
<factory class="Symfony\Component\Cache\Adapter\RedisAdapter" method="createConnection"/>
340378
<argument>redis://localhost</argument>
341379
<argument type="collection">
342380
<argument key="retry_interval">2</argument>
@@ -349,6 +387,8 @@ and use that when configuring the pool.
349387
.. code-block:: php
350388
351389
// config/packages/cache.php
390+
use Symfony\Component\Cache\Adapter\RedisAdapter;
391+
352392
$container->loadFromExtension('framework', [
353393
'cache' => [
354394
'pools' => [
@@ -360,12 +400,14 @@ and use that when configuring the pool.
360400
],
361401
]);
362402
363-
$container->getDefinition('app.my_custom_redis_provider', \Redis::class)
403+
$container->register('app.my_custom_redis_provider', \Redis::class)
404+
->setFactory([RedisAdapter::class, 'createConnection'])
364405
->addArgument('redis://localhost')
365406
->addArgument([
366407
'retry_interval' => 2,
367408
'timeout' => 10
368-
]);
409+
])
410+
;
369411
370412
Creating a Cache Chain
371413
----------------------
@@ -503,7 +545,9 @@ to enable this feature. This could be added by using the following configuration
503545
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
504546
xmlns:framework="http://symfony.com/schema/dic/symfony"
505547
xsi:schemaLocation="http://symfony.com/schema/dic/services
506-
https://symfony.com/schema/dic/services/services-1.0.xsd">
548+
https://symfony.com/schema/dic/services/services-1.0.xsd
549+
http://symfony.com/schema/dic/symfony
550+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
507551
508552
<framework:config>
509553
<framework:cache>
@@ -515,6 +559,9 @@ to enable this feature. This could be added by using the following configuration
515559
.. code-block:: php
516560
517561
// config/packages/cache.php
562+
use Symfony\Component\Cache\Adapter\ChainAdapter;
563+
use Symfony\Component\DependencyInjection\Reference;
564+
518565
$container->loadFromExtension('framework', [
519566
'cache' => [
520567
'pools' => [

‎configuration/using_parameters_in_dic.rst

Copy file name to clipboardExpand all lines: configuration/using_parameters_in_dic.rst
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ Now, examine the results to see this closely:
5151
5252
<?xml version="1.0" encoding="UTF-8" ?>
5353
<container xmlns="http://symfony.com/schema/dic/services"
54-
xmlns:my-bundle="http://example.org/schema/dic/my_bundle">
54+
xmlns:my-bundle="http://example.org/schema/dic/my_bundle"
55+
xsi:schemaLocation="http://symfony.com/schema/dic/services
56+
https://symfony.com/schema/dic/services/services-1.0.xsd
57+
http://example.org/schema/dic/my_bundle
58+
https://example.org/schema/dic/my_bundle/my_bundle-1.0.xsd">
5559
5660
<my-bundle:config logging="true"/>
5761
<!-- true, as expected -->

‎console/commands_as_services.rst

Copy file name to clipboardExpand all lines: console/commands_as_services.rst
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,24 @@ Or set the ``command`` attribute on the ``console.command`` tag in your service
8282
8383
# config/services.yaml
8484
services:
85+
# ...
86+
8587
App\Command\SunshineCommand:
8688
tags:
8789
- { name: 'console.command', command: 'app:sunshine' }
88-
# ...
8990
9091
.. code-block:: xml
9192
9293
<!-- config/services.xml -->
9394
<?xml version="1.0" encoding="UTF-8" ?>
9495
<container xmlns="http://symfony.com/schema/dic/services"
9596
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
96-
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
97+
xsi:schemaLocation="http://symfony.com/schema/dic/services
98+
https://symfony.com/schema/dic/services/services-1.0.xsd">
9799
98100
<services>
101+
<!-- ... -->
102+
99103
<service id="App\Command\SunshineCommand">
100104
<tag name="console.command" command="app:sunshine"/>
101105
</service>
@@ -106,10 +110,9 @@ Or set the ``command`` attribute on the ``console.command`` tag in your service
106110
107111
// config/services.php
108112
use App\Command\SunshineCommand;
109-
// ...
110113
111-
$container
112-
->register(SunshineCommand::class)
114+
// ...
115+
$container->register(SunshineCommand::class)
113116
->addTag('console.command', ['command' => 'app:sunshine'])
114117
;
115118

‎console/input.rst

Copy file name to clipboardExpand all lines: console/input.rst
+14-7Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ to greet all your friends). Only the last argument can be a list::
7474
'names',
7575
InputArgument::IS_ARRAY,
7676
'Who do you want to greet (separate multiple names with a space)?'
77-
);
77+
)
78+
;
7879

7980
To use this, specify as many names as you want:
8081

@@ -111,7 +112,8 @@ You can combine ``IS_ARRAY`` with ``REQUIRED`` and ``OPTIONAL`` like this::
111112
'names',
112113
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
113114
'Who do you want to greet (separate multiple names with a space)?'
114-
);
115+
)
116+
;
115117

116118
Using Command Options
117119
---------------------
@@ -135,7 +137,8 @@ how many times in a row the message should be printed::
135137
InputOption::VALUE_REQUIRED,
136138
'How many times should the message be printed?',
137139
1
138-
);
140+
)
141+
;
139142

140143
Next, use this in the command to print the message multiple times::
141144

@@ -177,7 +180,8 @@ flag:
177180
InputOption::VALUE_REQUIRED,
178181
'How many times should the message be printed?',
179182
1
180-
);
183+
)
184+
;
181185

182186
Note that to comply with the `docopt standard`_, long options can specify their
183187
values after a white space or an ``=`` sign (e.g. ``--iterations 5`` or
@@ -221,7 +225,8 @@ You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or
221225
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
222226
'Which colors do you like?',
223227
['blue', 'red']
224-
);
228+
)
229+
;
225230

226231
Options with optional arguments
227232
-------------------------------
@@ -239,7 +244,8 @@ optionally accepts a value, but it's a bit tricky. Consider this example::
239244
null,
240245
InputOption::VALUE_OPTIONAL,
241246
'Should I yell while greeting?'
242-
);
247+
)
248+
;
243249

244250
This option can be used in 3 ways: ``--yell``, ``yell=louder``, and not passing
245251
the option at all. However, it's hard to distinguish between passing the option
@@ -258,7 +264,8 @@ To solve this issue, you have to set the option's default value to ``false``::
258264
InputOption::VALUE_OPTIONAL,
259265
'Should I yell while greeting?',
260266
false // this is the new default value, instead of null
261-
);
267+
)
268+
;
262269

263270
Now check the value of the option and keep in mind that ``false !== null``::
264271

‎controller.rst

Copy file name to clipboardExpand all lines: controller.rst
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ the argument by its name:
231231
232232
# explicitly configure the service
233233
App\Controller\LuckyController:
234-
public: true
234+
tags: [controller.service_arguments]
235235
bind:
236236
# for any $logger argument, pass this specific service
237237
$logger: '@monolog.logger.doctrine'
@@ -251,7 +251,8 @@ the argument by its name:
251251
<!-- ... -->
252252
253253
<!-- Explicitly configure the service -->
254-
<service id="App\Controller\LuckyController" public="true">
254+
<service id="App\Controller\LuckyController">
255+
<tag name"controller.service_arguments"/>
255256
<bind key="$logger"
256257
type="service"
257258
id="monolog.logger.doctrine"
@@ -268,7 +269,7 @@ the argument by its name:
268269
use Symfony\Component\DependencyInjection\Reference;
269270
270271
$container->register(LuckyController::class)
271-
->setPublic(true)
272+
->addTag('controller.service_arguments')
272273
->setBindings([
273274
'$logger' => new Reference('monolog.logger.doctrine'),
274275
'$projectDir' => '%kernel.project_dir%'
@@ -278,6 +279,14 @@ the argument by its name:
278279
Like with all services, you can also use regular :ref:`constructor injection <services-constructor-injection>`
279280
in your controllers.
280281

282+
.. caution::
283+
284+
You can *only* pass *services* to your controller arguments in this way. It's not
285+
possible, for example, to pass a config parameter as a controller argument,
286+
even by using ``bind``. If you need a parameter, use the ``$this->getParameter('kernel.debug')``
287+
shortcut or pass the value through your controller's ``__construct()`` method
288+
and specify its value with ``bind``.
289+
281290
For more information about services, see the :doc:`/service_container` article.
282291

283292
Generating Controllers

‎controller/argument_value_resolver.rst

Copy file name to clipboardExpand all lines: controller/argument_value_resolver.rst
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ type-hinted method arguments:
101101
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
102102
xmlns:sensio-framework-extra="http://symfony.com/schema/dic/symfony_extra"
103103
xsi:schemaLocation="http://symfony.com/schema/dic/services
104-
https://symfony.com/schema/dic/services/services-1.0.xsd">
104+
https://symfony.com/schema/dic/services/services-1.0.xsd
105+
http://symfony.com/schema/dic/symfony_extra
106+
https://symfony.com/schema/dic/symfony_extra/symfony_extra-1.0.xsd">
105107
106108
<sensio-framework-extra:config>
107109
<request converters="true" auto-convert="false"/>
@@ -206,7 +208,8 @@ and adding a priority.
206208
<?xml version="1.0" encoding="UTF-8" ?>
207209
<container xmlns="http://symfony.com/schema/dic/services"
208210
xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
209-
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
211+
xsi:schemaLocation="http://symfony.com/schema/dic/services
212+
https://symfony.com/schema/dic/services/services-1.0.xsd">
210213
211214
<services>
212215
<!-- ... be sure autowiring is enabled -->
@@ -226,7 +229,8 @@ and adding a priority.
226229
use App\ArgumentResolver\UserValueResolver;
227230
228231
$container->autowire(UserValueResolver::class)
229-
->addTag('controller.argument_value_resolver', ['priority' => 50]);
232+
->addTag('controller.argument_value_resolver', ['priority' => 50])
233+
;
230234
231235
While adding a priority is optional, it's recommended to add one to make sure
232236
the expected value is injected. The ``RequestAttributeValueResolver`` has a

‎event_dispatcher.rst

Copy file name to clipboardExpand all lines: event_dispatcher.rst
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ using a special "tag":
102102
// config/services.php
103103
use App\EventListener\ExceptionListener;
104104
105-
$container
106-
->autowire(ExceptionListener::class)
105+
$container->register(ExceptionListener::class)
107106
->addTag('kernel.event_listener', ['event' => 'kernel.exception'])
108107
;
109108

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.