/** * @param FileFilter $previousFilter * @param $destFile * @param YuiCompressorPath $yuiCommpressorPath * @param int $filterUpdateMode */ public function __construct(FileFilter $previousFilter, $destFile, YuiCompressorPath $yuiCommpressorPath, $filterUpdateMode = FileFilter::CHECK_EXISTS_MTIME_AND_PREVIOUS) { $this->yuiCommpressorPath = $yuiCommpressorPath; $this->previousFilter = $previousFilter; $this->srcFile = $previousFilter->getFile(); $this->destFile = clone $destFile; //$this->modifyFilename($this->srcFile); $this->filterUpdateMode = $filterUpdateMode; }
function __construct($options = array()) { parent::__construct($options); $defaultOptions = array('type' => 'max', 'size' => 4 * MB); $options = am($defaultOptions, $options); $this->options = $options; }
/** * zipFiles * * @param SplFileInfo $file * @param SplFileInfo $sqlFile * * @return bool */ protected function zipFiles(\SplFileInfo $file, \SplFileInfo $sqlFile) { // Delete old file if (is_file($file->getPathname())) { @unlink($file->getPathname()); } $zip = new ZipArchive(); if ($zip->open($file->getPathname(), ZipArchive::CREATE) === true) { $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->getOption('root'), RecursiveDirectoryIterator::SKIP_DOTS)); $filter = new FileFilter($this->getOption('ignores'), $this->getOption('root')); /** @var \SplFileInfo $item */ foreach ($iterator as $item) { // Excludes if ($filter->test($item->getPathname())) { continue; } $dest = str_replace($this->getOption('root') . DIRECTORY_SEPARATOR, '', $item->getPathname()); if ($item->isDir()) { $zip->addEmptyDir($dest); continue; } $zip->addFile($item->getPathname(), $dest); } if ($this->getOption('dump_database', true)) { $zip->addFile($sqlFile->getPathname(), $sqlFile->getBasename()); } } return $zip->close(); }