Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc62f542

Browse files
committed
feature#11647 [DependencyInjection] Added optionignore_errors: not_found for imported config files (pulzarraider)
This PR was merged into the 4.4 branch.Discussion----------[DependencyInjection] Added option `ignore_errors: not_found` for imported config files<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/roadmap for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `master` for features of unreleased versions).-->Related merge request:symfony/symfony#31310Commits-------0a6873d [Configuration] Add documentation about `ignore_errors: not_found` option.
2 parents8a7d32e +0a6873d commitc62f542

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎configuration.rst‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ configuration files, even if they use a different format:
8888
# config/services.yaml
8989
imports:
9090
-{ resource: 'legacy_config.php' }
91-
# ignore_errors silently discards errors if the loaded file doesn't exist
92-
-{ resource: 'my_config_file.xml', ignore_errors: true }
91+
9392
# glob expressions are also supported to load multiple files
9493
-{ resource: '/etc/myapp/*.yaml' }
9594
95+
# ignore_errors: not_found silently discards errors if the loaded file doesn't exist
96+
-{ resource: 'my_config_file.xml', ignore_errors: not_found }
97+
# ignore_errors: true silently discards all errors (including invalid code and not found)
98+
-{ resource: 'my_other_config_file.xml', ignore_errors: true }
99+
96100
# ...
97101
98102
..code-block::xml
@@ -108,10 +112,13 @@ configuration files, even if they use a different format:
108112
109113
<imports>
110114
<importresource="legacy_config.php"/>
111-
<!-- ignore_errors silently discards errors if the loaded file doesn't exist-->
112-
<importresource="my_config_file.yaml"ignore-errors="true"/>
113115
<!-- glob expressions are also supported to load multiple files-->
114116
<importresource="/etc/myapp/*.yaml"/>
117+
118+
<!-- ignore-errors="not_found" silently discards errors if the loaded file doesn't exist-->
119+
<importresource="my_config_file.yaml"ignore-errors="not_found"/>
120+
<!-- ignore-errors="true" silently discards all errors (including invalid code and not found)-->
121+
<importresource="my_other_config_file.yaml"ignore-errors="true"/>
115122
</imports>
116123
117124
<!-- ...-->
@@ -124,14 +131,23 @@ configuration files, even if they use a different format:
124131
125132
return static function (ContainerConfigurator $container) {
126133
$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);
134+
129135
// glob expressions are also supported to load multiple files
130136
$container->import('/etc/myapp/*.yaml');
137+
138+
// the third optional argument of import() is 'ignore_errors'
139+
// 'ignore_errors' set to 'not_found' silently discards errors if the loaded file doesn't exist
140+
$container->import('my_config_file.yaml', null, 'not_found');
141+
// 'ignore_errors' set to true silently discards all errors (including invalid code and not found)
142+
$container->import('my_config_file.yaml', null, true);
131143
};
132144
133145
// ...
134146
147+
..versionadded::4.4
148+
149+
The ``not_found`` option value for ``ignore_errors`` was introduced in Symfony 4.4.
150+
135151
.. _config-parameter-intro:
136152
.. _config-parameters-yml:
137153
.. _configuration-parameters:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp