Skip to content

Commit b5079ba

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Updated some config file paths Use "closure-style" PHP configuration format in code examples [Security] Mention the feature to use a custom AccessDecisionManager Update bundles.rst [Console] Update input.rst
2 parents 326281d + 2a672a0 commit b5079ba

File tree

4 files changed

+122
-45
lines changed

4 files changed

+122
-45
lines changed

bundles.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ file::
3131
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
3232
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
3333
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
34-
// this bundle is enabled only in 'dev' and 'test', so you can't use it in 'prod'
34+
// this bundle is enabled only in 'dev' and 'test', so you can't use it in 'prod'
3535
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
3636
];
3737

configuration.rst

Lines changed: 74 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ configuration files, even if they use a different format:
120120
.. code-block:: php
121121
122122
// config/services.php
123-
$loader->import('legacy_config.xml');
124-
// the third optional argument of import() is 'ignore_errors', which
125-
// silently discards errors if the loaded file doesn't exist
126-
$loader->import('my_config_file.yaml', null, true);
127-
// glob expressions are also supported to load multiple files
128-
$loader->import('/etc/myapp/*.yaml');
123+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
124+
125+
return static function (ContainerConfigurator $container) {
126+
$container->import('legacy_config.php');
127+
// ignore_errors (3rd parameter) silently discards errors if the loaded file doesn't exist
128+
$container->import('my_config_file.xml', null, true);
129+
// glob expressions are also supported to load multiple files
130+
$container->import('/etc/myapp/*.yaml');
131+
};
129132
130133
// ...
131134
@@ -209,24 +212,29 @@ reusable configuration value. By convention, parameters are defined under the
209212
.. code-block:: php
210213
211214
// config/services.php
212-
// the parameter name is an arbitrary string (the 'app.' prefix is recommended
213-
// to better differentiate your parameters from Symfony parameters).
214-
$container->setParameter('app.admin_email', 'something@example.com');
215+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
215216
216-
// boolean parameters
217-
$container->setParameter('app.enable_v2_protocol', true);
217+
use App\Entity\BlogPost;
218218
219-
// array/collection parameters
220-
$container->setParameter('app.supported_locales', ['en', 'es', 'fr']);
219+
return static function (ContainerConfigurator $container) {
220+
$container->parameters()
221+
// the parameter name is an arbitrary string (the 'app.' prefix is recommended
222+
// to better differentiate your parameters from Symfony parameters).
223+
->set('app.admin_email', 'something@example.com')
221224
222-
// binary content parameters (use the PHP escape sequences)
223-
$container->setParameter('app.some_parameter', 'This is a Bell char: \x07');
225+
// boolean parameters
226+
->set('app.enable_v2_protocol', true)
224227
225-
// PHP constants as parameter values
226-
use App\Entity\BlogPost;
228+
// array/collection parameters
229+
->set('app.supported_locales', ['en', 'es', 'fr'])
227230
228-
$container->setParameter('app.some_constant', GLOBAL_CONSTANT);
229-
$container->setParameter('app.another_constant', BlogPost::MAX_ITEMS);
231+
// binary content parameters (use the PHP escape sequences)
232+
->set('app.some_parameter', 'This is a Bell char: \x07')
233+
234+
// PHP constants as parameter values
235+
->set('app.some_constant', GLOBAL_CONSTANT)
236+
->set('app.another_constant', BlogPost::MAX_ITEMS);
237+
};
230238
231239
// ...
232240
@@ -278,12 +286,17 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
278286
.. code-block:: php
279287
280288
// config/packages/some_package.php
281-
$container->loadFromExtension('some_package', [
282-
// any string surrounded by two % is replaced by that parameter value
283-
'email_address' => '%app.admin_email%',
289+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
290+
291+
return static function (ContainerConfigurator $container) {
292+
$container->extension('some_package', [
293+
// any string surrounded by two % is replaced by that parameter value
294+
'email_address' => '%app.admin_email%',
295+
296+
// ...
297+
]);
298+
};
284299
285-
// ...
286-
]);
287300
288301
.. note::
289302

@@ -310,7 +323,12 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
310323
.. code-block:: php
311324
312325
// config/services.php
313-
$container->setParameter('url_pattern', 'http://symfony.com/?foo=%%s&bar=%%d');
326+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
327+
328+
return static function (ContainerConfigurator $container) {
329+
$container->parameters()
330+
->set('url_pattern', 'http://symfony.com/?foo=%%s&bar=%%d');
331+
};
314332
315333
.. include:: /components/dependency_injection/_imports-parameters-note.rst.inc
316334

@@ -478,12 +496,16 @@ This example shows how you could configure the database connection using an env
478496
.. code-block:: php
479497
480498
// config/packages/doctrine.php
481-
$container->loadFromExtension('doctrine', [
482-
'dbal' => [
483-
// by convention the env var names are always uppercase
484-
'url' => '%env(resolve:DATABASE_URL)%',
485-
]
486-
]);
499+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
500+
501+
return static function (ContainerConfigurator $container) {
502+
$container->extension('doctrine', [
503+
'dbal' => [
504+
// by convention the env var names are always uppercase
505+
'url' => '%env(resolve:DATABASE_URL)%',
506+
]
507+
]);
508+
};
487509
488510
.. seealso::
489511

@@ -772,13 +794,18 @@ doesn't work for parameters:
772794
.. code-block:: php
773795
774796
// config/services.php
797+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
798+
775799
use App\Service\MessageGenerator;
776-
use Symfony\Component\DependencyInjection\Reference;
777800
778-
$container->setParameter('app.contents_dir', '...');
801+
return static function (ContainerConfigurator $container) {
802+
$container->parameters()
803+
->set('app.contents_dir', '...');
779804
780-
$container->getDefinition(MessageGenerator::class)
781-
->setArgument('$contentsDir', '%app.contents_dir%');
805+
$container->services()
806+
->get(MessageGenerator::class)
807+
->arg('$contentsDir', '%app.contents_dir%');
808+
};
782809
783810
If you inject the same parameters over and over again, use the
784811
``services._defaults.bind`` option instead. The arguments defined in that option are
@@ -824,18 +851,22 @@ whenever a service/controller defines a ``$projectDir`` argument, use this:
824851
.. code-block:: php
825852
826853
// config/services.php
854+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
855+
827856
use App\Controller\LuckyController;
828857
use Psr\Log\LoggerInterface;
829858
use Symfony\Component\DependencyInjection\Reference;
830859
831-
$container->register(LuckyController::class)
832-
->setPublic(true)
833-
->setBindings([
834-
// pass this value to any $projectDir argument for any service
835-
// that's created in this file (including controller arguments)
836-
'$projectDir' => '%kernel.project_dir%',
837-
])
838-
;
860+
return static function (ContainerConfigurator $container) {
861+
$container->services()
862+
->set(LuckyController::class)
863+
->public()
864+
->args([
865+
// pass this value to any $projectDir argument for any service
866+
// that's created in this file (including controller arguments)
867+
'$projectDir' => '%kernel.project_dir%',
868+
]);
869+
};
839870
840871
.. seealso::
841872

console/input.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ There are three argument variants you can use:
106106
The argument can contain any number of values. For that reason, it must be
107107
used at the end of the argument list.
108108

109-
You can combine ``IS_ARRAY`` with ``REQUIRED`` and ``OPTIONAL`` like this::
109+
You can combine ``IS_ARRAY`` with ``REQUIRED`` or ``OPTIONAL`` like this::
110110

111111
$this
112112
// ...

security/voters.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,49 @@ security configuration:
313313
'allow_if_all_abstain' => false,
314314
],
315315
]);
316+
317+
Custom Access Decision Strategy
318+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319+
320+
If none of the built-in strategies fits your use case, define the ``service``
321+
option to use a custom service as the Access Decision Manager (your service
322+
must implement the :class:`Symfony\\Component\\Security\\Core\\Authorization\\AccessDecisionManagerInterface`):
323+
324+
.. configuration-block::
325+
326+
.. code-block:: yaml
327+
328+
# config/packages/security.yaml
329+
security:
330+
access_decision_manager:
331+
service: App\Security\MyCustomAccessDecisionManager
332+
# ...
333+
334+
.. code-block:: xml
335+
336+
<!-- config/packages/security.xml -->
337+
<?xml version="1.0" encoding="UTF-8" ?>
338+
<srv:container xmlns="http://symfony.com/schema/dic/security"
339+
xmlns:srv="http://symfony.com/schema/dic/services"
340+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
341+
xsi:schemaLocation="http://symfony.com/schema/dic/services
342+
https://symfony.com/schema/dic/services/services-1.0.xsd"
343+
>
344+
345+
<config>
346+
<access-decision-manager
347+
service="App\Security\MyCustomAccessDecisionManager"/>
348+
</config>
349+
</srv:container>
350+
351+
.. code-block:: php
352+
353+
// config/packages/security.php
354+
use App\Security\MyCustomAccessDecisionManager;
355+
356+
$container->loadFromExtension('security', [
357+
'access_decision_manager' => [
358+
'service' => MyCustomAccessDecisionManager::class,
359+
// ...
360+
],
361+
]);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy