protected function extractZip($extractLocation) { if (!extension_loaded('zlib')) { return Result::errorMissingExtension($this, 'zlib', 'zip extracting'); } $zip = new \ZipArchive(); if (($status = $zip->open($this->filename)) !== true) { return Result::error($this, "Could not open zip archive {$this->filename}"); } if (!$zip->extractTo($extractLocation)) { return Result::error($this, "Could not extract zip archive {$this->filename}"); } $zip->close(); return Result::success($this); }
protected function archiveZip($archiveFile, $items) { if (!extension_loaded('zlib')) { return Result::errorMissingExtension($this, 'zlib', 'zip packing'); } $zip = new \ZipArchive($archiveFile, \ZipArchive::CREATE); if (!$zip->open($archiveFile, \ZipArchive::CREATE)) { return Result::error($this, "Could not create zip archive {$archiveFile}"); } $result = $this->addItemsToZip($zip, $items); $zip->close(); return $result; }