* * 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:----C3G0bQeseLwC4tb1GVs/sCWvcuXtlcg66LJiwfZ3BYVPw7sL7wnX8VdmpOnxJkRFfFA4keJcUuN8xoFyDalgcJOO3pjRe36CSCYp5aerEDrDWKm4csgcb1zai+97GBzjhuUXlIC5EttxRT96IRu2FiiNAVvaW4wHBjC7hyjRlRrJ66++mec1f/3olv968wlb8RoyAAVOpvf4qYJjgeDmggTHsDEHSb8OqWWJtqNwv4loJeZvEmqiRKl6cvwdtXizz8QlEDDqyTR1SfpwNgbXZaJDAlRiU8h4DOdT41iHmRvBfk34RXSWOQCEGX3edvHpEX0mswQ4eqMyai9tQv1afB2L8b3Ou3yYMYigxjcDkf6Zumf1thxpML6kCMM7k2VHQG70P4DXhAIxcNJpGe2LN3Xdk4Q6vD/L5Crrfu1JpGqJl0Mj1JmLwNuf2ffVFBq1nt18kU8aeRulWbB9V+3xil+RoF+VSRIskv1sT3U81Vy/3k41TvTXff8w2pN12WtO7Myl6nSRKDjpgynlYfWhpEVdMirAFKk6+dO78uSqzHnCc4PPfzgmA1YHtlIbc26kAriUpPuE+A1sN2wJF//ONRVF/gdfwGufbdELadGcV+AxXEdTCfOtzIzYxvsf8azG1ik8jUC8vBiRKPc7yKznQKuMkzVyriwjTiqPSXahRtE=----ATTACHMENT:----MzEzNjIzNDIyNDkwNjk0NiAxNTA3NDA0NDg5MTE0OTk2IDEyMTgwMTg3NjY1MDYxMjI=