[Config] Implemented Serializable on resources

This commit is contained in:
Christophe Coevoet 2011-11-01 02:15:01 +01:00
parent c2fa73d33a
commit cbd0c3c8e9
2 changed files with 22 additions and 2 deletions

View File

@ -16,7 +16,7 @@ namespace Symfony\Component\Config\Resource;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
class DirectoryResource implements ResourceInterface class DirectoryResource implements ResourceInterface, \Serializable
{ {
private $resource; private $resource;
private $pattern; private $pattern;
@ -89,4 +89,14 @@ class DirectoryResource implements ResourceInterface
return $newestMTime < $timestamp; return $newestMTime < $timestamp;
} }
public function serialize()
{
return serialize(array($this->resource, $this->pattern));
}
public function unserialize($serialized)
{
list($this->resource, $this->pattern) = unserialize($serialized);
}
} }

View File

@ -18,7 +18,7 @@ namespace Symfony\Component\Config\Resource;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
class FileResource implements ResourceInterface class FileResource implements ResourceInterface, \Serializable
{ {
private $resource; private $resource;
@ -67,4 +67,14 @@ class FileResource implements ResourceInterface
return filemtime($this->resource) < $timestamp; return filemtime($this->resource) < $timestamp;
} }
public function serialize()
{
return serialize($this->resource);
}
public function unserialize($serialized)
{
$this->resource = unserialize($serialized);
}
} }