/** * Compiles the file without executing directives. */ protected function compileFileBody($file) { $tempFilePath = $this->tempFolder() . '/' . $file->subPathsPath() . $file->name() . '-body' . ($this->config['compress'] ? '-c' : '') . '.' . $file->type(); $dir = pathinfo($tempFilePath, PATHINFO_DIRNAME); if (!is_dir($dir)) { mkdir($dir, 0775, true); } $recompile = true; if (is_file($tempFilePath)) { $tempFileMTime = filemtime($tempFilePath); if (filemtime($file->originalFilePath()) <= $tempFileMTime) { $recompile = false; } } if ($recompile) { $processor = new Processor\Processor($this); $compiledFile = $processor->compileFile($file); $compiledFile = $this->compressCompiledFile($file->type(), $compiledFile); # Cache compiled file. file_put_contents($tempFilePath, $compiledFile); } return ['file' => $file, 'tempFilePath' => $tempFilePath]; }
protected function buildAssetTag($type, Closure $builder, $sources, array $options) { $sources = (array) $sources; $tags = []; if (isset($options['protocol'])) { $protocol = $options['protocol']; unset($options['protocol']); } else { $protocol = ''; } if ($this->config['serve_static_assets']) { foreach ($sources as &$source) { $this->ensureAssetType($type, $source); } // if ($this->config['use_cache']) { // $key = 'asset-tags-' . crc32(implode($sources)); // if ($tags = $this->getService('rails.cache')->read($key)) { // return $tags; // } // $tags = []; // } foreach ($sources as $source) { $this->appendAssetTag($source, $type, $builder, $options, false, $tags); } // if ($this->config['use_cache']) { // $this->getService('rails.cache')->write($key, implode("\n", $tags)); // } } else { if ($this->config['assets']['concat']) { foreach ($sources as $source) { $this->ensureAssetType($type, $source); $this->compileAssetFile($source); $this->appendAssetTag($source, $type, $builder, $options, false, $tags); } } else { $assets = $this->getService('assets'); $processor = new AssetProcessor($assets); foreach ($sources as $source) { $this->ensureAssetType($type, $source); $file = $assets->findFile($source); if (!$file) { $this->compileAssetFile($source); $this->appendAssetTag($source, $type, $builder, $options, true, $tags); continue; } $processor->listFiles($file); foreach ($processor->files() as $subFile) { $this->compileAssetFile($subFile->logicalPath()); $this->appendAssetTag($subFile->url(), $type, $builder, $options, true, $tags); } } } } return implode("\n", $tags); }