Skip to content

Commit 10356c8

Browse files
Merge branch '7.4' into 8.0
* 7.4: [DependencyInjection][Routing] Fix nested config imports when returning PHP arrays fix compatibility with Relay 0.12.1 [TypeInfo] Fix resolving use statements with line breaks [FrameworkBundle] Fix normalization of enums in workflow transitions Add missing return type for docblock Closure don't use a fixed date fixture when assertions depend on relative times [FrameworkBundle] Fix secrets:encrypt-from-local [Security] Add support for `Sec-Fetch-Site` to `SameOriginCsrfTokenManager` [Console] Optimize mostRecentlyEnteredValue() method [HttpClient] Add QUERY to the list of retriable HTTP methods Update regular expression in URL validator [AssetMapper] Fix parsing @import that don't use url() [Messenger] Add retry delay on amazon sqs [Serializer] CsvEncoder to escape values starting with line feed when escape formulas is enabled
2 parents b2c94d8 + 287e74a commit 10356c8

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

Loader/PhpFileLoader.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Config\Builder\ConfigBuilderGeneratorInterface;
1616
use Symfony\Component\Config\Builder\ConfigBuilderInterface;
1717
use Symfony\Component\Config\FileLocatorInterface;
18+
use Symfony\Component\Config\Loader\LoaderResolver;
1819
use Symfony\Component\DependencyInjection\Attribute\When;
1920
use Symfony\Component\DependencyInjection\Attribute\WhenNot;
2021
use Symfony\Component\DependencyInjection\Container;
@@ -109,8 +110,14 @@ public function load(mixed $resource, ?string $type = null): mixed
109110
throw new InvalidArgumentException(\sprintf('Invalid key "%s" returned for the "%s" config builder; none or "services" expected in file "%s".', $key, get_debug_type($config), $path));
110111
}
111112
$yamlLoader = new YamlFileLoader($this->container, $this->locator, $this->env, $this->prepend);
113+
$yamlLoader->setResolver(new LoaderResolver([$this]));
112114
$loadContent = new \ReflectionMethod(YamlFileLoader::class, 'loadContent');
113-
$loadContent->invoke($yamlLoader, ContainerConfigurator::processValue((array) $config), $path);
115+
++$this->importing;
116+
try {
117+
$loadContent->invoke($yamlLoader, ContainerConfigurator::processValue((array) $config), $path);
118+
} finally {
119+
--$this->importing;
120+
}
114121
} elseif ($config instanceof ConfigBuilderInterface) {
115122
if (\is_string($key) && $config->getExtensionAlias() !== $key) {
116123
throw new InvalidArgumentException(\sprintf('The extension alias "%s" of the "%s" config builder does not match the key "%s" in file "%s".', $config->getExtensionAlias(), get_debug_type($config), $key, $path));
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
43
use Symfony\Component\DependencyInjection\Tests\Fixtures\AcmeConfig;
54

65
if ('prod' !== $env) {
76
return;
87
}
98

10-
return function (AcmeConfig $config, ContainerConfigurator $c) {
11-
$c->import('nested_config_builder.php');
12-
13-
$config->color('blue');
14-
};
9+
return [
10+
'imports' => [
11+
'nested_config_builder.php',
12+
],
13+
new AcmeConfig(['color' => 'blue']),
14+
];

Tests/Loader/PhpFileLoaderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function testPrependExtensionConfigWithLoadMethod()
6666
$container = new ContainerBuilder();
6767
$container->registerExtension(new \AcmeExtension());
6868
$container->prependExtensionConfig('acme', ['foo' => 'bar']);
69-
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Fixtures'), 'prod', new ConfigBuilderGenerator(sys_get_temp_dir()), true);
70-
$loader->load('config/config_builder.php');
69+
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Fixtures/config'), 'prod', new ConfigBuilderGenerator(sys_get_temp_dir()), true);
70+
$loader->load('config_builder.php');
7171

7272
$expected = [
7373
['color' => 'red'],
@@ -82,8 +82,8 @@ public function testPrependExtensionConfigWithImportMethod()
8282
$container = new ContainerBuilder();
8383
$container->registerExtension(new \AcmeExtension());
8484
$container->prependExtensionConfig('acme', ['foo' => 'bar']);
85-
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Fixtures'), 'prod', new ConfigBuilderGenerator(sys_get_temp_dir()), true);
86-
$loader->import('config/config_builder.php');
85+
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Fixtures/config'), 'prod', new ConfigBuilderGenerator(sys_get_temp_dir()), true);
86+
$loader->import('config_builder.php');
8787

8888
$expected = [
8989
['color' => 'red'],

0 commit comments

Comments
 (0)