public function testResource()
 {
     $resource = new CumulativeResource('test', new CumulativeResourceLoaderCollection());
     $resource->addFound('bundle', 'path');
     $this->assertEquals('test', $resource->getResource());
     $this->assertEquals('test', $resource->__toString());
     $this->assertTrue($resource->isFound('bundle', 'path'));
     $this->assertFalse($resource->isFound('bundle', 'path1'));
     $this->assertFalse($resource->isFound('bundle1', 'path'));
 }
 /**
  * {@inheritdoc}
  */
 public function isResourceFresh($bundleClass, $bundleDir, CumulativeResource $resource, $timestamp)
 {
     // check exist and removed resources
     $found = $resource->getFound($bundleClass);
     foreach ($found as $path) {
         if (!is_file($path) || filemtime($path) >= $timestamp) {
             return false;
         }
     }
     // check new resources
     $finder = $this->getFileFinder($bundleDir);
     if ($finder) {
         /** @var \SplFileInfo $file */
         foreach ($finder as $file) {
             $path = $file->getRealPath();
             if (!$resource->isFound($bundleClass, $path)) {
                 return false;
             }
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function isResourceFresh($bundleClass, $bundleDir, $bundleAppDir, CumulativeResource $resource, $timestamp)
 {
     if (is_dir($bundleAppDir)) {
         $path = $bundleAppDir . preg_replace('/Resources\\//', '', $this->relativeFilePath, 1);
         if ($resource->isFound($bundleClass, $path)) {
             // check exists and removed resource
             return is_file($path) && filemtime($path) < $timestamp;
         }
         // check new resource
         if (is_file($path)) {
             return false;
         }
     }
     $path = $bundleDir . $this->relativeFilePath;
     if ($resource->isFound($bundleClass, $path)) {
         // check exists and removed resource
         return is_file($path) && filemtime($path) < $timestamp;
     }
     // check new resource
     return !is_file($path);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function isResourceFresh($bundleClass, $bundleDir, CumulativeResource $resource, $timestamp)
 {
     $path = $bundleDir . $this->relativeFilePath;
     if ($resource->isFound($bundleClass, $path)) {
         // check exists and removed resource
         return is_file($path) && filemtime($path) < $timestamp;
     } else {
         // check new resource
         return !is_file($path);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function isResourceFresh($bundleClass, $bundleDir, $bundleAppDir, CumulativeResource $resource, $timestamp)
 {
     $registeredFiles = $resource->getFound($bundleClass);
     $registeredFiles = array_flip($registeredFiles);
     // Check and remove data from $bundleAppDir resources directory
     if (is_dir($bundleAppDir)) {
         $dir = $this->getResourcesDirectoryAbsolutePath($bundleAppDir);
         $realPath = realpath($dir);
         if (is_dir($realPath)) {
             $currentContents = $this->getDirectoryContentsArray($realPath);
             foreach ($currentContents as $filename) {
                 if (!$resource->isFound($bundleClass, $filename)) {
                     return false;
                 }
                 unset($registeredFiles[$filename]);
             }
         }
     }
     // Check and remove data from $bundleDir resources directory
     $dir = $this->getDirectoryAbsolutePath($bundleDir);
     $realPath = realpath($dir);
     if (is_dir($realPath)) {
         $currentContents = $this->getDirectoryContentsArray($realPath);
         foreach ($currentContents as $filename) {
             if (!$resource->isFound($bundleClass, $filename)) {
                 return false;
             }
             unset($registeredFiles[$filename]);
         }
     }
     // case when entire dir was removed or some file was removed
     if (!empty($registeredFiles)) {
         return false;
     }
     return true;
 }