From 77f56a61f6910057dd3a9844372c5cdae55640a9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Apr 2010 16:47:59 +0200 Subject: [PATCH] [Foundation] made the Kernel serializable (to avoid weird error messages when used with PHPUnit) --- src/Symfony/Foundation/Kernel.php | 14 +++++++++++++- src/Symfony/Foundation/bootstrap.php | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 9ee03a2156..666fd137dc 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -25,7 +25,7 @@ use Symfony\Components\RequestHandler\RequestInterface; * @package Symfony * @author Fabien Potencier */ -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); + } } diff --git a/src/Symfony/Foundation/bootstrap.php b/src/Symfony/Foundation/bootstrap.php index aa0d7ab502..189f61bb4e 100644 --- a/src/Symfony/Foundation/bootstrap.php +++ b/src/Symfony/Foundation/bootstrap.php @@ -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); + } }