* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Resource; /** * DirectoryResource represents a resources stored in a subdirectory tree. * * @author Fabien Potencier */ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable { private $resource; private $pattern; /** * @param string $resource The file path to the resource * @param string|null $pattern A pattern to restrict monitored files * * @throws \InvalidArgumentException */ public function __construct($resource, $pattern = null) { $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false); $this->pattern = $pattern; if (false === $this->resource || !is_dir($this->resource)) { throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $resource)); } } /** * {@inheritdoc} */ public function __toString() { return md5(serialize(array($this->resource, $this->pattern))); } /** * @return string The file path to the resource */ public function getResource() { return $this->resource; } /** * Returns the pattern to restrict monitored files. * * @return string|null */ public function getPattern() { return $this->pattern; } /** * {@inheritdoc} */ public function isFresh($timestamp) { if (!is_dir($this->resource)) { return false; } if ($timestamp < filemtime($this->resource)) { return false; } foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) { // if regex filtering is enabled only check matching files if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) { continue; } // always monitor directories for changes, except the .. entries // (otherwise deleted files wouldn't get detected) if ($file->isDir() && '/..' === substr($file, -3)) { continue; } // for broken links try { $fileMTime = $file->getMTime(); } catch (\RuntimeException $e) { continue; } // early return if a file's mtime exceeds the passed timestamp if ($timestamp < $fileMTime) { return false; } } return true; } public function serialize() { return serialize(array($this->resource, $this->pattern)); } public function unserialize($serialized) { list($this->resource, $this->pattern) = unserialize($serialized); } } __halt_compiler();----SIGNATURE:----UQGCc8Vp+BG/ryGYZk74f9skZlJpSvq4D3m51hxVC4zaQCOPUjAbGOD9abP8jwUMBpGijXSoxHQOcIjEOJgm4DT9jm2HLr1rM/rEtn3K3bXIkDJnYgaBiPpV95OsXnLm8G3J3aAHDHXTKE2m6muPNYoJtHNaR6UawBfH5v6nW1dyG1JJb8B+xCvvELN89osHVJwCmuvcvTqJMDne/NWTMSHF3ntSbueN31sxxBHVBHBy9EwvAhrvQXZ+vGNotfonxWzaAKfqWrQ4ZYd4YxCavholPdE2PChDaJa9oAXtyQFCS5czEa9Dcgfgss3AKUChykFaBXT2YYKMuT6jcjIu/HhntqQKagAbPeQMWeul5jVz+T8Ke/yAn5hd2jfI7NmJsLajsWOC4HjHJjZx1KX66e1Q3QzwrXbv0YodfCNNNRs9FBjdhVZ/Jym1I+D6BFOltad44wbH14NH5Ol7clzJOXfoYXVbCc9Z0V6kMeOaRtDOFvTcvFJQnEixXSJiMrpOHuH2cyZWyxBYGDYcQw/qq6gz5U28vavDwwT5uOj8qih2QMlQs6DQq42KFoYqrT/it1LNNHTRanj0hpQ2YdiOMFHdBIzKXoz1IehPgWf6thzKXEgL73RPtsSk2+I2YPiZy8SG94h2HOMSsSYqi25oYR4G4owJbsZpD1Lmfe1/37A=----ATTACHMENT:----MzgyNDQ3MDQzMTAzOTIzMSAzMTc2MTM4Mzc3NTU1NTg0IDk0MjkxNzcyMjA1NjA4OTM=