\App\CoreModule\ModelsZipArchiveManager

Tool for creating a new zip archive

Summary

Methods
Properties
Constants
__construct()
addFileFromText()
addFolder()
addFile()
addJsonFromArray()
exist()
extract()
listFiles()
openFile()
close()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$zip
N/A

Properties

$zip

$zip : \ZipArchive

Type

\ZipArchive — ZIP archive

Methods

__construct()

__construct(string  $path, int  $flags = ZipArchive::CREATE | ZipArchive::OVERWRITE) : mixed

Constructor

Parameters

string $path

Path of a new zip archive

int $flags

The mode to use to open the archive

Returns

mixed

addFileFromText()

addFileFromText(string  $filename, string  $content) : void

Adds a file to the ZIP archive using its contents

Parameters

string $filename

File name

string $content

The content of text file

addFolder()

addFolder(string  $path, string  $name) : void

Adds a folder to the ZIP archive from the given path

Parameters

string $path

The path to the folder to add

string $name

Directory name in the archive

addFile()

addFile(string  $path, string  $filename) : void

Adds a file to a ZIP archive from the given path

Parameters

string $path

The path to the file to add

string $filename

File name in the archive

addJsonFromArray()

addJsonFromArray(string  $filename, array  $jsonData) : void

Adds a JSON file to the ZIP archive using its contents

Parameters

string $filename

File name

array $jsonData

JSON data in an array

Throws

\Nette\Utils\JsonException

exist()

exist(string|array|iterable|mixed  $var) : bool

Checks if the file or the files exist in the archive

Parameters

string|array|iterable|mixed $var

File(s) to check

Returns

bool —

Is file exist

extract()

extract(string  $destinationPath) : void

Extracts the archive contents

Parameters

string $destinationPath

Path to location where to extract the files

listFiles()

listFiles() : string[]

Lists files in the archive

Returns

string[] —

List of files in the archive

openFile()

openFile(string  $fileName) : string

Opens file in the archive

Parameters

string $fileName

File name

Returns

string —

Content of file

close()

close() : void

Closes the active archive