Merge remote branch 'schmittjoh/containerBaseClass'

* schmittjoh/containerBaseClass:
  [DependencyInjection] make base class of generated container configurable
This commit is contained in:
Fabien Potencier 2011-04-17 14:15:36 +02:00
commit 7a70236437

View File

@ -435,6 +435,18 @@ abstract class Kernel implements KernelInterface
return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
}
/**
* Gets the container's base class.
*
* All names except Container must be fully qualified.
*
* @return string
*/
protected function getContainerBaseClass()
{
return 'Container';
}
/**
* Initializes the service container.
*
@ -448,7 +460,7 @@ abstract class Kernel implements KernelInterface
$fresh = true;
if (!$cache->isFresh()) {
$container = $this->buildContainer();
$this->dumpContainer($cache, $container, $class);
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
$fresh = false;
}
@ -556,12 +568,13 @@ abstract class Kernel implements KernelInterface
* @param ConfigCache $cache The config cache
* @param ContainerBuilder $container The service container
* @param string $class The name of the class to generate
* @param string $baseClass The name of the container's base class
*/
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class)
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
{
// cache the container
$dumper = new PhpDumper($container);
$content = $dumper->dump(array('class' => $class));
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
if (!$this->debug) {
$content = self::stripComments($content);
}