[Foundation] made the Kernel serializable (to avoid weird error messages when used with PHPUnit)

This commit is contained in:
Fabien Potencier 2010-04-02 16:47:59 +02:00
parent 5b941f58cb
commit 77f56a61f6
2 changed files with 26 additions and 2 deletions

View File

@ -25,7 +25,7 @@ use Symfony\Components\RequestHandler\RequestInterface;
* @package Symfony
* @author Fabien Potencier <fabien.potencier@symfony-project.org>
*/
abstract class Kernel
abstract class Kernel implements \Serializable
{
protected $bundles;
protected $bundleDirs;
@ -380,4 +380,16 @@ abstract class Kernel
@rename($tmpFile, $file);
chmod($file, 0644);
}
public function serialize()
{
return serialize(array($this->environment, $this->debug));
}
public function unserialize($data)
{
list($environment, $debug) = unserialize($data);
$this->__construct($environment, $debug);
}
}

View File

@ -320,7 +320,7 @@ use Symfony\Components\DependencyInjection\FileResource;
use Symfony\Components\RequestHandler\RequestInterface;
abstract class Kernel
abstract class Kernel implements \Serializable
{
protected $bundles;
protected $bundleDirs;
@ -649,6 +649,18 @@ abstract class Kernel
@rename($tmpFile, $file);
chmod($file, 0644);
}
public function serialize()
{
return serialize(array($this->environment, $this->debug));
}
public function unserialize($data)
{
list($environment, $debug) = unserialize($data);
$this->__construct($environment, $debug);
}
}