diff --git a/Config/FastDirectoriesResource.php b/Config/FastDirectoriesResource.php index 719ac41..3303623 100644 --- a/Config/FastDirectoriesResource.php +++ b/Config/FastDirectoriesResource.php @@ -32,8 +32,7 @@ class FastDirectoriesResource implements ResourceInterface public function __construct(array $directories, $filePattern = null) { - $this->finder = new PatternFinder('.*', '*.php'); - $this->finder->setRegexPattern(true); + $this->createFinder(); $this->directories = $directories; $this->filePattern = $filePattern ?: '*'; @@ -71,8 +70,51 @@ public function isFresh($timestamp) return true; } + public function exists() + { + return true; + } + + public function getId() + { + return md5('jms_di_extra'.$this->filePattern.$this->files); + } + + public function getModificationTime() + { + return -1; + } + + public function serialize() + { + $resourceMap = array( + 'directories' => $this->directories, + 'filePattern' => $this->filePattern, + 'files' => $this->files, + ); + + return serialize($resourceMap); + } + + public function unserialize($serialized) + { + $resourceMap = unserialize($serialized); + + $this->directories = $resourceMap['directories']; + $this->filePattern = $resourceMap['filePattern']; + $this->files = $resourceMap['files']; + + $this->createFinder(); + } + private function getFiles() { return $this->finder->findFiles($this->directories); } + + private function createFinder() + { + $this->finder = new PatternFinder('.*', '*.php'); + $this->finder->setRegexPattern(true); + } } \ No newline at end of file diff --git a/Config/ServiceFilesResource.php b/Config/ServiceFilesResource.php index 40508b2..10fb0af 100644 --- a/Config/ServiceFilesResource.php +++ b/Config/ServiceFilesResource.php @@ -40,6 +40,21 @@ public function isFresh($timestamp) return !array_diff($files, $this->files) && !array_diff($this->files, $files); } + public function exists() + { + return true; + } + + public function getId() + { + return md5('jms_di_extra'.$this->files.$this->dirs); + } + + public function getModificationTime() + { + return -1; + } + public function __toString() { return implode(', ', $this->files); @@ -49,4 +64,23 @@ public function getResource() { return array($this->files, $this->dirs); } + + public function serialize() + { + $resourceMap = array( + 'files' => $this->files, + 'dirs' => $this->dirs, + ); + + return serialize($resourceMap); + } + + public function unserialize($serialized) + { + $resourceMap = unserialize($serialized); + + $this->files = $resourceMap['files']; + $this->dirs = $resourceMap['dirs']; + } + } \ No newline at end of file