Skip to content

Instantly share code, notes, and snippets.

@marcw
Created October 19, 2012 20:12
Show Gist options
  • Save marcw/3920410 to your computer and use it in GitHub Desktop.
Save marcw/3920410 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
static protected $databaseDefaultConnection;
public function registerBundles()
{
// ...
}
public function boot()
{
parent::boot();
if ('test' === $this->getEnvironment()) {
if (null === static::$databaseDefaultConnection) {
static::$databaseDefaultConnection = $this->getContainer()->get('doctrine.dbal.default_connection');
} else {
$this->getContainer()->set('doctrine.dbal.default_connection', static::$databaseDefaultConnection);
}
}
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment