Skip to content

Commit 61faeff

Browse files
committed
Revert "Responsibility for loading config files moved from ContainerFactory to Compiler (BC break)"
This reverts commit 5b7f9b9.
1 parent d0ca3ac commit 61faeff

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

src/DI/Compiler.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Compiler extends Nette\Object
2929
private $builder;
3030

3131
/** @var array */
32-
private $config = array();
32+
private $config;
3333

3434
/** @var array reserved section names */
3535
private static $reserved = array('services' => 1, 'factories' => 1, 'parameters' => 1);
@@ -75,27 +75,6 @@ public function getContainerBuilder()
7575
}
7676

7777

78-
/**
79-
* Sets configuration.
80-
* @param array
81-
* @param array [file => section]
82-
* @return ContainerBuilder
83-
*/
84-
public function setConfig(array $config, array $files = NULL)
85-
{
86-
$this->config = array();
87-
$loader = new Config\Loader;
88-
foreach ($files as $info) {
89-
$this->config = Config\Helpers::merge($loader->load($info[0], $info[1]), $this->config);
90-
}
91-
foreach ($loader->getDependencies() as $file) {
92-
$this->builder->addDependency($file);
93-
}
94-
$this->config = Config\Helpers::merge($this->config, $config);
95-
return $this;
96-
}
97-
98-
9978
/**
10079
* Returns configuration.
10180
* @return array
@@ -109,9 +88,9 @@ public function getConfig()
10988
/**
11089
* @return string
11190
*/
112-
public function compile(array $config = NULL, $className, $parentName = NULL)
91+
public function compile(array $config, $className, $parentName = NULL)
11392
{
114-
$this->config = $config ?: $this->config;
93+
$this->config = $config;
11594
$this->processParameters();
11695
$this->processExtensions();
11796
$this->processServices();

src/DI/ContainerFactory.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ public function create()
6666
protected function generateCode()
6767
{
6868
$compiler = $this->createCompiler();
69-
$compiler->setConfig($this->config, $this->configFiles);
70-
$this->onCompile($this, $compiler, $compiler->getConfig());
69+
$config = $this->generateConfig();
70+
$this->onCompile($this, $compiler, $config);
7171

7272
$code = "<?php\n";
7373
foreach ($this->configFiles as $info) {
7474
$code .= "// source: $info[0] $info[1]\n";
7575
}
76-
$code .= "\n" . $compiler->compile(NULL, $this->class, $this->parentClass);
76+
$code .= "\n" . $compiler->compile($config, $this->class, $this->parentClass);
7777

7878
if ($this->autoRebuild !== 'compat') { // back compatibility
7979
$this->dependencies = array_merge($this->dependencies, $compiler->getContainerBuilder()->getDependencies());
@@ -82,6 +82,22 @@ protected function generateCode()
8282
}
8383

8484

85+
/**
86+
* @return array
87+
*/
88+
protected function generateConfig()
89+
{
90+
$config = array();
91+
$loader = $this->createLoader();
92+
foreach ($this->configFiles as $info) {
93+
$config = Config\Helpers::merge($loader->load($info[0], $info[1]), $config);
94+
}
95+
$this->dependencies = array_merge($this->dependencies, $loader->getDependencies());
96+
97+
return Config\Helpers::merge($config, $this->config);
98+
}
99+
100+
85101
/**
86102
* @return void
87103
*/

0 commit comments

Comments
 (0)