Exemplo n.º 1
0
 /**
  * Check to see if a cached build file is 'fresh'.
  * Fresh cached files have timestamps newer than all of the component
  * files.
  *
  * @param string $target The target file being built.
  * @return boolean
  */
 public function isFresh($target)
 {
     $ext = $this->_Config->getExt($target);
     $files = $this->_Config->files($target);
     $theme = $this->_Config->theme();
     $target = $this->buildFileName($target);
     $buildFile = $this->_Config->cachePath($ext) . $target;
     if (!file_exists($buildFile)) {
         return false;
     }
     $buildTime = filemtime($buildFile);
     $Scanner = new AssetScanner($this->_Config->paths($ext), $theme);
     foreach ($files as $file) {
         $path = $Scanner->find($file);
         if ($Scanner->isRemote($path)) {
             $time = $this->getRemoteFileLastModified($path);
         } else {
             $time = filemtime($path);
         }
         if ($time === false || $time >= $buildTime) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 2
0
 public function testIsRemote()
 {
     $paths = array($this->_testFiles . 'css' . DS);
     $scanner = new AssetScanner($paths);
     $this->assertFalse($scanner->isRemote('/Users/markstory/cakephp'));
     $this->assertFalse($scanner->isRemote('C:\\Project\\cakephp'));
     $this->assertTrue($scanner->isRemote('http://example.com'));
 }