Skip to content

Commit c80564c

Browse files
committed
Remove one dependency
1 parent 1c6451a commit c80564c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@
3333
class PhpFileLoader extends FileLoader
3434
{
3535
protected $autoRegisterAliasesForSinglyImplementedInterfaces = false;
36-
private $buildDir;
3736
private $generator;
3837

39-
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator, string $env = null, string $buildDir = null, ConfigBuilderGeneratorInterface $generator = null)
38+
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator, string $env = null, ConfigBuilderGeneratorInterface $generator = null)
4039
{
4140
parent::__construct($container, $locator, $env);
42-
$this->buildDir = $buildDir;
4341
$this->generator = $generator;
4442
}
4543

@@ -147,8 +145,8 @@ private function configBuilder(string $namespace): ConfigBuilderInterface
147145
throw new \LogicException('You cannot use the config builder as the Config component is not installed. Try running "composer require symfony/config".');
148146
}
149147

150-
if (null === $this->buildDir) {
151-
throw new \LogicException('You cannot use the config builder without providing a path to the directory where to store the generated ConfigBuilders.');
148+
if (null === $this->generator) {
149+
throw new \LogicException('You cannot use the config builder without providing a class implementing ConfigBuilderGeneratorInterface.');
152150
}
153151

154152
// If class exists and implements ConfigBuilderInterface
@@ -175,7 +173,6 @@ private function configBuilder(string $namespace): ConfigBuilderInterface
175173
}
176174

177175
$configuration = $extension->getConfiguration([], $this->container);
178-
$this->generator = $this->generator ?? new ConfigBuilderGenerator($this->buildDir);
179176
$loader = $this->generator->build($configuration);
180177

181178
return $loader();

src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use PHPUnit\Framework\TestCase;
1717
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
18+
use Symfony\Component\Config\Builder\ConfigBuilderGenerator;
1819
use Symfony\Component\Config\FileLocator;
1920
use Symfony\Component\DependencyInjection\ContainerBuilder;
2021
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
@@ -64,7 +65,7 @@ public function testConfig($file)
6465
$fixtures = realpath(__DIR__.'/../Fixtures');
6566
$container = new ContainerBuilder();
6667
$container->registerExtension(new \AcmeExtension());
67-
$loader = new PhpFileLoader($container, new FileLocator(), 'prod', sys_get_temp_dir());
68+
$loader = new PhpFileLoader($container, new FileLocator(), 'prod', new ConfigBuilderGenerator(sys_get_temp_dir()));
6869
$loader->load($fixtures.'/config/'.$file.'.php');
6970

7071
$container->compile();

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
1515
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
16+
use Symfony\Component\Config\Builder\ConfigBuilderGenerator;
1617
use Symfony\Component\Config\ConfigCache;
1718
use Symfony\Component\Config\Loader\DelegatingLoader;
1819
use Symfony\Component\Config\Loader\LoaderResolver;
@@ -758,7 +759,7 @@ protected function getContainerLoader(ContainerInterface $container)
758759
new XmlFileLoader($container, $locator, $env),
759760
new YamlFileLoader($container, $locator, $env),
760761
new IniFileLoader($container, $locator, $env),
761-
new PhpFileLoader($container, $locator, $env, $this->getBuildDir()),
762+
new PhpFileLoader($container, $locator, $env, new ConfigBuilderGenerator($this->getBuildDir())),
762763
new GlobFileLoader($container, $locator, $env),
763764
new DirectoryLoader($container, $locator, $env),
764765
new ClosureLoader($container, $env),

0 commit comments

Comments
 (0)