Skip to content

Commit 4d84c04

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Ensure config blocks are consistent
2 parents d29ee51 + d24ec84 commit 4d84c04

File tree

11 files changed

+153
-91
lines changed

11 files changed

+153
-91
lines changed

bundles/best_practices.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ The end user can provide values in any configuration file:
427427
<container xmlns="http://symfony.com/schema/dic/services"
428428
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
429429
xsi:schemaLocation="http://symfony.com/schema/dic/services
430-
https://symfony.com/schema/dic/services/services-1.0.xsd">
431-
430+
https://symfony.com/schema/dic/services/services-1.0.xsd"
431+
>
432432
<parameters>
433433
<parameter key="acme_blog.author.email">fabien@example.com</parameter>
434434
</parameters>
@@ -438,7 +438,13 @@ The end user can provide values in any configuration file:
438438
.. code-block:: php
439439
440440
// config/services.php
441-
$container->setParameter('acme_blog.author.email', 'fabien@example.com');
441+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
442+
443+
return static function (ContainerConfigurator $container) {
444+
$container->parameters()
445+
->set('acme_blog.author.email', 'fabien@example.com')
446+
;
447+
};
442448
443449
Retrieve the configuration parameters in your code from the container::
444450

bundles/configuration.rst

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,30 @@ as integration of other related components:
2020

2121
.. code-block:: yaml
2222
23+
# config/packages/framework.yaml
2324
framework:
2425
form: true
2526
2627
.. code-block:: xml
2728
29+
<!-- config/packages/framework.xml -->
2830
<?xml version="1.0" encoding="UTF-8" ?>
2931
<container xmlns="http://symfony.com/schema/dic/services"
32+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3033
xmlns:framework="http://symfony.com/schema/dic/symfony"
3134
xsi:schemaLocation="http://symfony.com/schema/dic/services
3235
https://symfony.com/schema/dic/services/services-1.0.xsd
3336
http://symfony.com/schema/dic/symfony
34-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
35-
37+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
38+
>
3639
<framework:config>
3740
<framework:form/>
3841
</framework:config>
3942
</container>
4043
4144
.. code-block:: php
4245
46+
// config/packages/framework.php
4347
use Symfony\Config\FrameworkConfig;
4448
4549
return static function (FrameworkConfig $framework) {
@@ -71,13 +75,13 @@ can add some configuration that looks like this:
7175
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7276
xmlns:acme-social="http://example.org/schema/dic/acme_social"
7377
xsi:schemaLocation="http://symfony.com/schema/dic/services
74-
https://symfony.com/schema/dic/services/services-1.0.xsd">
75-
78+
https://symfony.com/schema/dic/services/services-1.0.xsd"
79+
>
7680
<acme-social:config>
77-
<acme-social:twitter client-id="123" client-secret="your_secret"/>
81+
<acme-social:twitter client-id="123"
82+
client-secret="your_secret"
83+
/>
7884
</acme-social:config>
79-
80-
<!-- ... -->
8185
</container>
8286
8387
.. code-block:: php
@@ -241,8 +245,8 @@ For example, imagine your bundle has the following example config:
241245
<container xmlns="http://symfony.com/schema/dic/services"
242246
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
243247
xsi:schemaLocation="http://symfony.com/schema/dic/services
244-
https://symfony.com/schema/dic/services/services-1.0.xsd">
245-
248+
https://symfony.com/schema/dic/services/services-1.0.xsd"
249+
>
246250
<services>
247251
<service id="acme.social.twitter_client" class="Acme\SocialBundle\TwitterClient">
248252
<argument></argument> <!-- will be filled in with client_id dynamically -->
@@ -422,8 +426,8 @@ Assuming the XSD file is called ``hello-1.0.xsd``, the schema location will be
422426
xsi:schemaLocation="http://symfony.com/schema/dic/services
423427
https://symfony.com/schema/dic/services/services-1.0.xsd
424428
http://acme_company.com/schema/dic/hello
425-
https://acme_company.com/schema/dic/hello/hello-1.0.xsd">
426-
429+
https://acme_company.com/schema/dic/hello/hello-1.0.xsd"
430+
>
427431
<acme-hello:config>
428432
<!-- ... -->
429433
</acme-hello:config>

bundles/override.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ to a new validation group:
139139
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
140140
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
141141
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
142-
https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
143-
142+
https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"
143+
>
144144
<class name="FOS\UserBundle\Model\User">
145145
<property name="plainPassword">
146146
<constraint name="NotBlank">

bundles/prepend_extension.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,29 +127,35 @@ registered and the ``entity_manager_name`` setting for ``acme_hello`` is set to
127127
http://example.org/schema/dic/acme_something
128128
https://example.org/schema/dic/acme_something/acme_something-1.0.xsd
129129
http://example.org/schema/dic/acme_other
130-
https://example.org/schema/dic/acme_something/acme_other-1.0.xsd">
131-
130+
https://example.org/schema/dic/acme_something/acme_other-1.0.xsd"
131+
>
132132
<acme-something:config use-acme-goodbye="false">
133133
<!-- ... -->
134134
<acme-something:entity-manager-name>non_default</acme-something:entity-manager-name>
135135
</acme-something:config>
136136
137-
<acme-other:config use-acme-goodbye="false"/>
137+
<acme-other:config use-acme-goodbye="false">
138+
<!-- ... -->
139+
</acme-other:config>
138140
139141
</container>
140142
141143
.. code-block:: php
142144
143145
// config/packages/acme_something.php
144-
$container->loadFromExtension('acme_something', [
145-
// ...
146-
'use_acme_goodbye' => false,
147-
'entity_manager_name' => 'non_default',
148-
]);
149-
$container->loadFromExtension('acme_other', [
150-
// ...
151-
'use_acme_goodbye' => false,
152-
]);
146+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
147+
148+
return static function (ContainerConfigurator $container) {
149+
$container->extension('acme_something', [
150+
// ...
151+
'use_acme_goodbye' => false,
152+
'entity_manager_name' => 'non_default',
153+
]);
154+
$container->extension('acme_other', [
155+
// ...
156+
'use_acme_goodbye' => false,
157+
]);
158+
};
153159
154160
More than one Bundle using PrependExtensionInterface
155161
----------------------------------------------------

cache.rst

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
7878
xsi:schemaLocation="http://symfony.com/schema/dic/services
7979
https://symfony.com/schema/dic/services/services-1.0.xsd
8080
http://symfony.com/schema/dic/symfony
81-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
82-
81+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
82+
>
8383
<framework:config>
84-
<framework:cache app="cache.adapter.filesystem"
84+
<framework:cache
85+
app="cache.adapter.filesystem"
8586
system="cache.adapter.system"
8687
/>
8788
</framework:config>
@@ -99,7 +100,6 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
99100
;
100101
};
101102
102-
103103
The Cache component comes with a series of adapters pre-configured:
104104

105105
* :doc:`cache.adapter.apcu </components/cache/adapters/apcu_adapter>`
@@ -149,8 +149,8 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
149149
xsi:schemaLocation="http://symfony.com/schema/dic/services
150150
https://symfony.com/schema/dic/services/services-1.0.xsd
151151
http://symfony.com/schema/dic/symfony
152-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
153-
152+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
153+
>
154154
<framework:config>
155155
<!--
156156
default_doctrine_provider: Service: cache.doctrine
@@ -250,8 +250,8 @@ You can also create more customized pools:
250250
xsi:schemaLocation="http://symfony.com/schema/dic/services
251251
https://symfony.com/schema/dic/services/services-1.0.xsd
252252
http://symfony.com/schema/dic/symfony
253-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
254-
253+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
254+
>
255255
<framework:config>
256256
<framework:cache default-memcached-provider="memcached://localhost">
257257
<!-- creates a "custom_thing.cache" service
@@ -352,6 +352,8 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
352352
353353
# config/services.yaml
354354
services:
355+
# ...
356+
355357
app.cache.adapter.redis:
356358
parent: 'cache.adapter.redis'
357359
tags:
@@ -364,9 +366,11 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
364366
<container xmlns="http://symfony.com/schema/dic/services"
365367
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
366368
xsi:schemaLocation="http://symfony.com/schema/dic/services
367-
https://symfony.com/schema/dic/services/services-1.0.xsd">
368-
369+
https://symfony.com/schema/dic/services/services-1.0.xsd"
370+
>
369371
<services>
372+
<!-- ... -->
373+
370374
<service id="app.cache.adapter.redis" parent="cache.adapter.redis">
371375
<tag name="cache.pool" namespace="my_custom_namespace"/>
372376
</service>
@@ -378,12 +382,14 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
378382
// config/services.php
379383
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
380384
381-
return function(ContainerConfigurator $configurator) {
382-
$services = $configurator->services();
385+
return function(ContainerConfigurator $container) {
386+
$container->services()
387+
// ...
383388
384-
$services->set('app.cache.adapter.redis')
385-
->parent('cache.adapter.redis')
386-
->tag('cache.pool', ['namespace' => 'my_custom_namespace']);
389+
->set('app.cache.adapter.redis')
390+
->parent('cache.adapter.redis')
391+
->tag('cache.pool', ['namespace' => 'my_custom_namespace'])
392+
;
387393
};
388394
389395
Custom Provider Options
@@ -425,11 +431,14 @@ and use that when configuring the pool.
425431
xsi:schemaLocation="http://symfony.com/schema/dic/services
426432
https://symfony.com/schema/dic/services/services-1.0.xsd
427433
http://symfony.com/schema/dic/symfony
428-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
429-
434+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
435+
>
430436
<framework:config>
431437
<framework:cache>
432-
<framework:pool name="cache.my_redis" adapter="cache.adapter.redis" provider="app.my_custom_redis_provider"/>
438+
<framework:pool name="cache.my_redis"
439+
adapter="cache.adapter.redis"
440+
provider="app.my_custom_redis_provider"
441+
/>
433442
</framework:cache>
434443
</framework:config>
435444
@@ -448,6 +457,8 @@ and use that when configuring the pool.
448457
.. code-block:: php
449458
450459
// config/packages/cache.php
460+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
461+
451462
use Symfony\Component\Cache\Adapter\RedisAdapter;
452463
use Symfony\Component\DependencyInjection\ContainerBuilder;
453464
use Symfony\Config\FrameworkConfig;
@@ -511,11 +522,14 @@ Symfony stores the item automatically in all the missing pools.
511522
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
512523
xmlns:framework="http://symfony.com/schema/dic/symfony"
513524
xsi:schemaLocation="http://symfony.com/schema/dic/services
514-
https://symfony.com/schema/dic/services/services-1.0.xsd">
515-
525+
https://symfony.com/schema/dic/services/services-1.0.xsd
526+
http://symfony.com/schema/dic/symfony
527+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
528+
>
516529
<framework:config>
517530
<framework:cache>
518-
<framework:pool name="my_cache_pool" default-lifetime="31536000">
531+
<framework:pool name="my_cache_pool"
532+
default-lifetime="31536000"> <!-- One year -->
519533
<framework:adapter name="cache.adapter.array"/>
520534
<framework:adapter name="cache.adapter.apcu"/>
521535
<framework:adapter name="cache.adapter.redis" provider="redis://user:password@example.com"/>
@@ -606,11 +620,14 @@ to enable this feature. This could be added by using the following configuration
606620
xsi:schemaLocation="http://symfony.com/schema/dic/services
607621
https://symfony.com/schema/dic/services/services-1.0.xsd
608622
http://symfony.com/schema/dic/symfony
609-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
610-
623+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
624+
>
611625
<framework:config>
612626
<framework:cache>
613-
<framework:pool name="my_cache_pool" adapter="cache.adapter.redis" tags="true"/>
627+
<framework:pool name="my_cache_pool"
628+
adapter="cache.adapter.redis"
629+
tags="true"
630+
/>
614631
</framework:cache>
615632
</framework:config>
616633
</container>
@@ -654,12 +671,17 @@ achieved by specifying the adapter.
654671
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
655672
xmlns:framework="http://symfony.com/schema/dic/symfony"
656673
xsi:schemaLocation="http://symfony.com/schema/dic/services
657-
https://symfony.com/schema/dic/services/services-1.0.xsd">
658-
674+
https://symfony.com/schema/dic/services/services-1.0.xsd
675+
http://symfony.com/schema/dic/symfony
676+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
677+
>
659678
<framework:config>
660679
<framework:cache>
661-
<framework:pool name="my_cache_pool" adapter="cache.adapter.redis" tags="tag_pool"/>
662-
<framework:pool name="tag_pool" adapter="cache.adapter.apcu"/>
680+
<framework:pool name="my_cache_pool"
681+
adapter="cache.adapter.redis"
682+
tags="tag_pool"
683+
/>
684+
<framework:pool name="tag_pool" adapter="cache.adapter.apcu"/>
663685
</framework:cache>
664686
</framework:config>
665687
</container>

components/dependency_injection.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,16 @@ config files:
259259
newsletter_manager:
260260
class: NewsletterManager
261261
calls:
262-
- setMailer: ['@mailer']
262+
- [setMailer, ['@mailer']]
263263
264264
.. code-block:: xml
265265
266266
<?xml version="1.0" encoding="UTF-8" ?>
267267
<container xmlns="http://symfony.com/schema/dic/services"
268268
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
269-
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
270-
269+
xsi:schemaLocation="http://symfony.com/schema/dic/services
270+
https://symfony.com/schema/dic/services/services-1.0.xsd"
271+
>
271272
<parameters>
272273
<!-- ... -->
273274
<parameter key="mailer.transport">sendmail</parameter>
@@ -290,13 +291,15 @@ config files:
290291
291292
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
292293
293-
return function(ContainerConfigurator $configurator) {
294-
$configurator->parameters()
294+
return static function (ContainerConfigurator $container) {
295+
$container->parameters()
295296
// ...
296297
->set('mailer.transport', 'sendmail')
297298
;
298299
299-
$services = $configurator->services();
300+
$container->services()
301+
->set('mailer', 'Mailer')
302+
->args(['%mailer.transport%'])
300303
301304
$services->set('mailer', 'Mailer')
302305
// the param() method was introduced in Symfony 5.2.

components/dependency_injection/_imports-parameters-note.rst.inc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<container xmlns="http://symfony.com/schema/dic/services"
2020
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2121
xsi:schemaLocation="http://symfony.com/schema/dic/services
22-
https://symfony.com/schema/dic/services/services-1.0.xsd">
23-
22+
https://symfony.com/schema/dic/services/services-1.0.xsd"
23+
>
2424
<imports>
2525
<import resource="%kernel.project_dir%/somefile.yaml"/>
2626
</imports>
@@ -29,4 +29,8 @@
2929
.. code-block:: php
3030

3131
// config/services.php
32-
$loader->import('%kernel.project_dir%/somefile.yaml');
32+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
33+
34+
return static function (ContainerConfigurator $container) {
35+
$container->import('%kernel.project_dir%/somefile.yaml');
36+
};

0 commit comments

Comments
 (0)