コード例 #1
0
 /**
  * Recursively process asset
  * @param array $dependencies Collection of assets for compilation
  */
 protected function processAsset($dependencies)
 {
     foreach ($dependencies as $source => $nothing) {
         // Read asset content
         $content = $this->fileManager->read($source);
         $extension = pathinfo($source, PATHINFO_EXTENSION);
         // Resource dependant resources
         $innerDependencies = [];
         // Compile content
         $compiled = $content;
         Event::fire(self::E_COMPILE, [$source, &$extension, &$compiled, &$innerDependencies]);
         // Write compiled asset
         $target = $this->getAssetProcessedPath($source);
         $this->fileManager->write($target, $compiled);
         $this->fileManager->touch($target, $this->fileManager->lastModified($source));
         // Go deeper in recursion
         $this->processAsset($innerDependencies);
     }
 }
コード例 #2
0
ファイル: ResourceTest.php プロジェクト: samsonphp/resource
 public function setUp()
 {
     $this->fileManager = new LocalFileManager();
     $this->resource = new ResourceManager($this->fileManager);
     // Switch paths to testing environment
     ResourceManager::$excludeFolders = ['*/tests/cache/*'];
     ResourceManager::$projectRoot = __DIR__ . '/';
     ResourceManager::$webRoot = __DIR__ . '/www/';
     ResourceManager::$cacheRoot = __DIR__ . '/cache/';
     // Remove cache folder
     if ($this->fileManager->exists(ResourceManager::$cacheRoot)) {
         $this->fileManager->remove(ResourceManager::$cacheRoot);
     }
     // Create files
     for ($i = 1; $i < 3; $i++) {
         $parent = implode('/', array_fill(0, $i, 'folder'));
         foreach (ResourceManager::TYPES as $type) {
             $file = $parent . '/test' . $i . '.' . $type;
             $this->fileManager->write(__DIR__ . '/' . $file, '/** TEST */');
             $this->files[] = $file;
         }
     }
 }
コード例 #3
0
ファイル: Module.php プロジェクト: samsonphp/less
 /**
  * Cache LESS resources importing dependency trees.
  */
 public function cacheDependencies()
 {
     $this->fileManager->write($this->dependencyCache, serialize($this->dependencies));
 }