protected function processFile($file, &$contents) { $compressor = new YuiCompressor(); $compressor->addContent(YuiCompressor::TYPE_JAVASCRIPT, $contents); $output = $compressor->minify(true); if ($output->minified && strlen($output->minified)) { $contents = $output->minified; } }
protected function saveTempFile() { if (count($this->files)) { $handle = fopen($this->getTempFile(), 'w+'); if ($handle !== false) { for ($i = 0; $i < count($this->files); $i++) { $file = $this->files[$i]; $content = null; $content = $this->loadFile($file); /* Load content from framework */ if ($content === null) { $content = $this->loadFile($this->path . $file); } // Try resources folder if ($content !== null) { $filePath = $_ENV['base_path'] . '/resources/' . $this->getExtension() . '/' . $file; if (is_file($filePath)) { $content = file_get_contents($filePath); } } if ($content !== null) { if (env('MINIFY_JS', false)) { $compressor = new YuiCompressor(); $compressor->addContent($this->extension, $content); $output = $compressor->minify(true); if ($output->minified && strlen($output->minified)) { $content = $output->minified; } } $buffer = '/* ' . $file . ' */' . chr(10) . $content; fwrite($handle, $buffer); // Unset buffer $buffer = null; } } fclose($handle); chmod($this->getTempFile(), 0755); } } }