示例#1
0
 private function createFileCollection(array $files)
 {
     $fileCollection = new FileCollection($this->root);
     foreach ($files as $file) {
         if ($this->isRemoteFile($file)) {
             $fileCollection->addRemoteFile($file);
         } else {
             $fileCollection->addFile($file);
         }
     }
     return $fileCollection;
 }
示例#2
0
 /**
  * Generate compiled file(s) and render link(s)
  */
 public function render()
 {
     $hasArgs = func_num_args() > 0;
     if ($hasArgs) {
         $backup = $this->compiler->getFileCollection();
         $newFiles = new FileCollection($backup->getRoot());
         $newFiles->addFiles(func_get_args());
         $this->compiler->setFileCollection($newFiles);
     }
     // remote files
     foreach ($this->compiler->getFileCollection()->getRemoteFiles() as $file) {
         echo $this->getElement($file), PHP_EOL;
     }
     foreach ($this->compiler->generate() as $file) {
         echo $this->getElement($this->tempPath . '/' . $file->file . '?' . $file->lastModified), PHP_EOL;
     }
     if ($hasArgs) {
         $this->compiler->setFileCollection($backup);
     }
 }
示例#3
0
 public function testSplFileInfo()
 {
     $this->object->addFile(new \SplFileInfo(__DIR__ . '/fixtures/a.txt'));
     $this->assertEquals(1, count($this->object->getFiles()));
 }
示例#4
0
 /**
  * @param array $fileNames
  * @param string|FALSE $media
  * @param string $stylesDir
  */
 private function lessComponentWrapper(array $fileNames, $media = NULL, $stylesDir = NULL)
 {
     if ($media === NULL) {
         $media = 'screen,projection,tv';
     }
     if ($stylesDir === NULL) {
         $stylesDir = __DIR__ . '/../styles';
     }
     $outputDirName = '/tmp/css';
     $fileCollection = new WebLoader\FileCollection($stylesDir);
     $fileCollection->addFiles($fileNames);
     $name = strtolower(substr($this->name, strrpos($this->name, ':') + 1)) . '.css';
     if (file_exists($stylesDir . '/' . $name)) {
         $files->addFile($name);
     }
     $compiler = WebLoader\Compiler::createCssCompiler($fileCollection, $this->context->parameters['wwwDir'] . $outputDirName);
     $filter = new WebLoader\Filter\LessFilter();
     $compiler->addFileFilter($filter);
     $control = new WebLoader\Nette\CssLoader($compiler, $this->template->basePath . $outputDirName);
     if (is_string($media)) {
         $control->setMedia($media);
     }
     return $control;
 }
示例#5
0
 /**
  * Attaches BowerLoader to the FileCollection instance.
  * @param FileCollection
  * @param string resource type (eg. "css")
  * @return void
  */
 public function attach(FileCollection $collection, $resource)
 {
     if ($this->prepend) {
         $files = $collection->getFiles();
         $remoteFiles = $collection->getRemoteFiles();
         $collection->clear();
     }
     $collection->addFiles($this->getFiles($resource));
     if ($this->prepend) {
         $collection->addFiles($files);
         $collection->addRemoteFiles($remoteFiles);
     }
 }