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
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
$allowPartialArchive
private
bool
$allowPartialArchive
= false
$directory
private
string
$directory
= ''
$errorMessage
private
string|null
$errorMessage
= null
$files
private
array<string|int, mixed>
$files
$folder
private
Folder|null
$folder
= null
$nodeFilters
private
array<int, callable(Node): Array>
$nodeFilters
= []
$successful
private
bool
$successful
= true
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
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
allowsPartialArchive()
Whether the archive may be created without the nodes excluded by node filters.
public
allowsPartialArchive() : bool
Tags
Return values
boolgetDirectory()
Returns folder path relative to user folder
public
getDirectory() : string
Use getFolder instead and use node API
Tags
Return values
stringgetErrorMessage()
Get the error message, if any
public
getErrorMessage() : string|null
Tags
Return values
string|nullgetExclusionReason()
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
Return values
string|nullgetFiles()
public
getFiles() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getFolder()
public
getFolder() : Folder|null
Tags
Return values
Folder|nullisPropagationStopped()
{@inheritDoc}
public
isPropagationStopped() : bool
Tags
Attributes
- #[Override]
Return values
boolisSuccessful()
public
isSuccessful() : bool
Tags
Return values
boolsetErrorMessage()
public
setErrorMessage(string $errorMessage) : void
Parameters
- $errorMessage : string
Tags
setSuccessful()
Set if the event was successful
public
setSuccessful(bool $successful) : void
Parameters
- $successful : bool
Tags
stopPropagation()
Stops the propagation of the event to further event listeners
public
stopPropagation() : void