Nextcloud PHP API (master)

BeforeZipCreatedEvent extends Event
in package

This event is triggered before an archive is created when a user requested downloading a folder or multiple files.

By setting successful to false the tar creation can be aborted and the download denied.

If allowsPartialArchive returns true, listeners should only block the archive creation if access to the entire directory or all files is denied. Single nodes can be excluded from the archive with addNodeFilter. Listeners can always block the whole archive with setSuccessful(false).

Tags
since
25.0.0

Table of Contents

Properties

$allowPartialArchive  : bool
$directory  : string
$errorMessage  : string|null
$files  : array<string|int, mixed>
$folder  : Folder|null
$nodeFilters  : array<int, callable(Node): Array>
$successful  : bool

Methods

__construct()  : mixed
Compatibility constructor
addNodeFilter()  : void
Adds a filter deciding whether a node is included in the archive.
allowsPartialArchive()  : bool
Whether the archive may be created without the nodes excluded by node filters.
getDirectory()  : string
Returns folder path relative to user folder
getErrorMessage()  : string|null
Get the error message, if any
getExclusionReason()  : string|null
Returns the reason given by the first filter excluding the node, or null if the node is to be included in the archive.
getFiles()  : array<string|int, mixed>
getFolder()  : Folder|null
isPropagationStopped()  : bool
{@inheritDoc}
isSuccessful()  : bool
setErrorMessage()  : void
setSuccessful()  : void
Set if the event was successful
stopPropagation()  : void
Stops the propagation of the event to further event listeners

Properties

Methods

__construct()

Compatibility constructor

public __construct(string|Folder $directory, array<int, string> $files[, bool $allowPartialArchive = false ]) : mixed
Parameters
$directory : string|Folder

Folder instance, or (deprecated) string path relative to user folder

$files : array<int, string>

Selected files, empty for folder selection

$allowPartialArchive : bool = false

True if excluded or missing files should not block the creation of the archive

Tags
since
25.0.0
31.0.0

support OCP\Files\Folder as $directory parameter - passing a string is deprecated now

36.0.0

$allowPartialArchive parameter

addNodeFilter()

Adds a filter deciding whether a node is included in the archive.

public addNodeFilter(callable(Node): Array $filter) : void

Excluding a folder also excludes all of its content.

Parameters
$filter : callable(Node): Array

returns null to include the node, or the reason for excluding it

Tags
since
36.0.0

allowsPartialArchive()

Whether the archive may be created without the nodes excluded by node filters.

public allowsPartialArchive() : bool
Tags
since
36.0.0
Return values
bool

getDirectory()

Returns folder path relative to user folder

public getDirectory() : string

Use getFolder instead and use node API

Tags
since
25.0.0
Return values
string

getErrorMessage()

Get the error message, if any

public getErrorMessage() : string|null
Tags
since
25.0.0
Return values
string|null

getExclusionReason()

Returns the reason given by the first filter excluding the node, or null if the node is to be included in the archive.

public getExclusionReason(Node $node) : string|null
Parameters
$node : Node
Tags
since
36.0.0
Return values
string|null

getFiles()

public getFiles() : array<string|int, mixed>
Tags
since
25.0.0
Return values
array<string|int, mixed>

isPropagationStopped()

{@inheritDoc}

public isPropagationStopped() : bool
Tags
since
22.0.0
see
StoppableEventInterface
Attributes
#[Override]
Return values
bool

setErrorMessage()

public setErrorMessage(string $errorMessage) : void
Parameters
$errorMessage : string
Tags
since
25.0.0

setSuccessful()

Set if the event was successful

public setSuccessful(bool $successful) : void
Parameters
$successful : bool
Tags
since
25.0.0

stopPropagation()

Stops the propagation of the event to further event listeners

public stopPropagation() : void
Tags
since
22.0.0
On this page

Search results