|
@@ -46,6 +46,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|
|
public function __construct(ParameterBagInterface $parameterBag = null)
|
|
|
{
|
|
|
parent::__construct($parameterBag);
|
|
|
+
|
|
|
+ $this->compiler = new Compiler();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -166,47 +168,35 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Adds a compiler pass at the end of the current passes
|
|
|
+ * Adds a compiler pass.
|
|
|
*
|
|
|
- * @param CompilerPassInterface $pass
|
|
|
- * @param string $type
|
|
|
+ * @param CompilerPassInterface $pass A compiler pass
|
|
|
+ * @param string $type The type of compiler pass
|
|
|
*/
|
|
|
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
|
|
|
{
|
|
|
- if (null === $this->compiler) {
|
|
|
- $this->initializeCompiler();
|
|
|
- }
|
|
|
-
|
|
|
$this->compiler->addPass($pass, $type);
|
|
|
|
|
|
$this->addObjectResource($pass);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns the compiler pass config which can then be modified
|
|
|
+ * Returns the compiler pass config which can then be modified.
|
|
|
*
|
|
|
- * @return PassConfig
|
|
|
+ * @return PassConfig The compiler pass config
|
|
|
*/
|
|
|
public function getCompilerPassConfig()
|
|
|
{
|
|
|
- if (null === $this->compiler) {
|
|
|
- $this->initializeCompiler();
|
|
|
- }
|
|
|
-
|
|
|
return $this->compiler->getPassConfig();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns the compiler instance
|
|
|
+ * Returns the compiler.
|
|
|
*
|
|
|
- * @return Compiler
|
|
|
+ * @return Compiler The compiler
|
|
|
*/
|
|
|
public function getCompiler()
|
|
|
{
|
|
|
- if (null === $this->compiler) {
|
|
|
- $this->initializeCompiler();
|
|
|
- }
|
|
|
-
|
|
|
return $this->compiler;
|
|
|
}
|
|
|
|
|
@@ -379,7 +369,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|
|
public function getExtensionConfig($name)
|
|
|
{
|
|
|
if (!isset($this->extensionConfigs[$name])) {
|
|
|
- return array(array());
|
|
|
+ $this->extensionConfigs[$name] = array();
|
|
|
}
|
|
|
|
|
|
return $this->extensionConfigs[$name];
|
|
@@ -401,8 +391,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|
|
*/
|
|
|
public function compile()
|
|
|
{
|
|
|
- if (null === $this->compiler) {
|
|
|
- $this->initializeCompiler();
|
|
|
+ foreach ($this->compiler->getPassConfig()->getPasses() as $pass) {
|
|
|
+ $this->addObjectResource($pass);
|
|
|
}
|
|
|
|
|
|
$this->compiler->compile($this);
|
|
@@ -836,19 +826,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|
|
return $tags;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Initializes the compiler
|
|
|
- *
|
|
|
- * @return void
|
|
|
- */
|
|
|
- protected function initializeCompiler()
|
|
|
- {
|
|
|
- $this->compiler = new Compiler();
|
|
|
- foreach ($this->compiler->getPassConfig()->getPasses() as $pass) {
|
|
|
- $this->addObjectResource($pass);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Returns the Service Conditionals.
|
|
|
*
|