[DependencyInjection] Added exception to avoid fatal during compile in a frozen dumped container

This commit is contained in:
Clément Gautier 2014-09-05 11:37:47 +02:00
parent eb1e3c344c
commit 2356eaad5f
4 changed files with 45 additions and 0 deletions

View File

@ -109,6 +109,7 @@ class PhpDumper extends Dumper
if ($this->container->isFrozen()) {
$code .= $this->addFrozenConstructor();
$code .= $this->addFrozenCompile();
} else {
$code .= $this->addConstructor();
}
@ -851,6 +852,26 @@ EOF;
return $code;
}
/**
* Adds the constructor for a frozen container.
*
* @return string
*/
private function addFrozenCompile()
{
return <<<EOF
/**
* {@inheritdoc}
*/
public function compile()
{
throw new LogicException("You cannot compile a dumped frozen container");
}
EOF;
}
/**
* Adds the methodMap property definition
*

View File

@ -40,6 +40,14 @@ class ProjectServiceContainer extends Container
$this->aliases = array();
}
/**
* {@inheritdoc}
*/
public function compile()
{
throw new LogicException("You cannot compile a dumped frozen container");
}
/**
* Gets the 'test' service.
*

View File

@ -38,6 +38,14 @@ class ProjectServiceContainer extends Container
$this->aliases = array();
}
/**
* {@inheritdoc}
*/
public function compile()
{
throw new LogicException("You cannot compile a dumped frozen container");
}
/**
* Gets the 'foo' service.
*

View File

@ -55,6 +55,14 @@ class ProjectServiceContainer extends Container
);
}
/**
* {@inheritdoc}
*/
public function compile()
{
throw new LogicException("You cannot compile a dumped frozen container");
}
/**
* Gets the 'bar' service.
*