Commit d95fb96
committed
feature #61885 [DependencyInjection] Handle returning arrays and config-builders from config files (nicolas-grekas)
This PR was merged into the 7.4 branch.
Discussion
----------
[DependencyInjection] Handle returning arrays and config-builders from config files
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues | -
| License | MIT
Another step on the path explored in #58771
This allows returning PHP arrays or config-builders from config files.
Several styles are supported, some examples below.
What this does *not* support is config trees under the `import`, `parameters` or `services` namespaces (that's for another PR).
Arrays:
```php
return [
'framework' => [...],
];
```
```php
return static function () {
yield 'framework' => [...];
];
```
Config builders (best DX together with #61879):
```php
return new FrameworkConfig([...]);
```
```php
return static function () {
return new FrameworkConfig([...]);
];
```
```php
// $env is always available in config files
if ('dev' === $env) {
return new FrameworkConfig([...]);
}
```
```php
return static function (string $env) {
if ('dev' === $env) {
yield new FrameworkConfig([...]);
}
};
```
Commits
-------
ff3fbd7 [DependencyInjection] Handle returning arrays and config-builders from config filesFile tree
8 files changed
+116
-14
lines changed- src/Symfony/Component/DependencyInjection
- Loader
- Tests
- Fixtures
- config
- Loader
8 files changed
+116
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Lines changed: 37 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
66 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
67 | 72 | | |
68 | | - | |
69 | | - | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
71 | 96 | | |
72 | 97 | | |
73 | 98 | | |
| |||
92 | 117 | | |
93 | 118 | | |
94 | 119 | | |
95 | | - | |
| 120 | + | |
96 | 121 | | |
97 | 122 | | |
98 | 123 | | |
| |||
125 | 150 | | |
126 | 151 | | |
127 | 152 | | |
128 | | - | |
| 153 | + | |
129 | 154 | | |
130 | 155 | | |
131 | 156 | | |
| |||
163 | 188 | | |
164 | 189 | | |
165 | 190 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | 191 | | |
170 | 192 | | |
171 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
172 | 197 | | |
173 | 198 | | |
174 | | - | |
175 | 199 | | |
176 | | - | |
177 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
178 | 203 | | |
179 | | - | |
180 | | - | |
181 | 204 | | |
182 | 205 | | |
183 | 206 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
322 | 368 | | |
0 commit comments