<?php
namespace ModulesAbstract\ImportedOrdersFileManager\Model\Filters; class DownloadAndCompress extends AbstractFilter { protected $folderTempName = NULL; protected function validateInput($input) { return true; } protected function checkFileAndUpdateAttributes($file) { $valid = true; if (!$this->folderTempName) { $folderTempName = \Engine\Dir::tempnam(sprintf("%s-%s", __CLASS__, \Engine\RandomGenerator::randomString(10))); if ($folderTempName === FALSE) { $valid = false; } $this->folderTempName = $folderTempName; } if (!\Engine\File::create($this->folderTempName.$file->getFullName(), $file->getContent())) { $valid = false; } return $valid; } public function createArchive() { $zip = new \App\Archive\Compress\Zip(); $fileName = \Engine\File::tempnam(sprintf("%s-%s.zip", __CLASS__, \Engine\RandomGenerator::randomString(10))); $zip ->open($this->folderTempName) ->setCompressionLevel(\App\Archive\Compress\Zip::COMPRESS_HIGH) ->compressTo($fileName) ->close(); \Engine\Dir::delete($this->folderTempName); return $fileName; } }