Skip to content

Commit

Permalink
[Foundation] made the Kernel serializable (to avoid weird error messa…
Browse files Browse the repository at this point in the history
…ges when used with PHPUnit)
  • Loading branch information
fabpot committed Apr 2, 2010
1 parent 5b941f5 commit 77f56a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/Symfony/Foundation/Kernel.php
Expand Up @@ -25,7 +25,7 @@
* @package Symfony
* @author Fabien Potencier <fabien.potencier@symfony-project.org>
*/
abstract class Kernel
abstract class Kernel implements \Serializable
{
protected $bundles;
protected $bundleDirs;
Expand Down Expand Up @@ -380,4 +380,16 @@ protected function writeCacheFile($file, $content)
@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);
}
}
14 changes: 13 additions & 1 deletion src/Symfony/Foundation/bootstrap.php
Expand Up @@ -320,7 +320,7 @@ static protected function writeCacheFile($file, $content)
use Symfony\Components\RequestHandler\RequestInterface;


abstract class Kernel
abstract class Kernel implements \Serializable
{
protected $bundles;
protected $bundleDirs;
Expand Down Expand Up @@ -649,6 +649,18 @@ protected function writeCacheFile($file, $content)
@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);
}
}


Expand Down

0 comments on commit 77f56a6

Please sign in to comment.