Skip to content

Commit

Permalink
[Config] Implemented Serializable on resources
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Nov 1, 2011
1 parent c2fa73d commit cbd0c3c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/Symfony/Component/Config/Resource/DirectoryResource.php
Expand Up @@ -16,7 +16,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class DirectoryResource implements ResourceInterface
class DirectoryResource implements ResourceInterface, \Serializable
{
private $resource;
private $pattern;
Expand Down Expand Up @@ -89,4 +89,14 @@ public function isFresh($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);
}
}
12 changes: 11 additions & 1 deletion src/Symfony/Component/Config/Resource/FileResource.php
Expand Up @@ -18,7 +18,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class FileResource implements ResourceInterface
class FileResource implements ResourceInterface, \Serializable
{
private $resource;

Expand Down Expand Up @@ -67,4 +67,14 @@ public function isFresh($timestamp)

return filemtime($this->resource) < $timestamp;
}

public function serialize()
{
return serialize($this->resource);
}

public function unserialize($serialized)
{
$this->resource = unserialize($serialized);
}
}

0 comments on commit cbd0c3c

Please sign in to comment.