PHP Класс DNDataArchive

The model can also represent a request to upload a file later, through offline processes like mailing a DVD. In order to associate and authenticate those requests easily, an upload token is generated for every archive. The "OriginalEnvironment" points to original source of this snapshot (the one it was backed up from). It will be empty if the snapshot has been created with offline process. The "Environment" denotes the ownership of the snapshot. It will be initially set to match the "OriginalEnvironment", but can be changed later. During the offline process the ownership can be set up arbitrarily. When moving snapshots, the file always remains in its initial location. The archive can have associations to {@link DNDataTransfer}: - Zero transfers if a manual upload was requested, but not fulfilled yet - One transfer with Direction=get for a backup from an environment - One or more transfers with Direction=push for a restore to an environment The "Author" is either the person creating the archive through a "backup" operation, the person uploading through a web form, or the person requesting a manual upload. The "Mode" is what the "Author" said the file includes (either 'only assets', 'only database', or both). This is used in the ArchiveList.ss template.
Наследование: extends DataObject
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
FileSize ( ) : string Calculates and returns a human-readable size of this archive file. If the file exists, it will determine whether to display the output in bytes, kilobytes, megabytes, or gigabytes.
attachFile ( string $sspakFilepath, DNDataTransfer $dataTransfer ) : boolean Attach an sspak file path to this archive and associate the transfer.
canDelete ( Member | null $member = null ) : boolean Whether a {@link Member} can delete this archive from staging area.
canDownload ( Member | null $member = null ) : true Whether a {@link Member} can download this archive to their PC.
canMoveTo ( DNEnvironment $targetEnv, Member | null $member = null ) : boolean Check if this member can move archive into the environment.
canRestore ( Member | null $member = null ) : true Whether a {@link Member} can restore this archive to an environment.
canView ( Member | null $member = null ) Inferred from both restore and backup permissions.
extractArchive ( string | null $workingDir = null ) : boolean Extract the current sspak contents into the given working directory.
fixArchivePermissions ( string | null $workingDir ) : boolean Given a path that already exists and contains an extracted sspak, including the assets, fix all of the file permissions so they're in a state ready to be pushed to remote servers.
generateFilename ( DNDataTransfer $dataTransfer ) : string Returns a unique filename, including project/environment/timestamp details.
generateFilepath ( DNDataTransfer $dataTransfer ) : string Returns a path unique to a specific transfer, including project/environment details.
generate_upload_token ( $chars = 8 ) : string Returns a unique token to correlate an offline item (posted DVD) with a specific archive placeholder.
getCMSFields ( )
getDefaultSearchContext ( )
getModeNice ( )
get_mode_map ( )
isPending ( ) : boolean Some archives don't have files attached to them yet, because a file has been posted offline and is waiting to be uploaded against this "archive placeholder".
onAfterDelete ( )
onBeforeWrite ( )
setArchiveFromFiles ( string | null $workingDir ) : boolean Given extracted sspak contents, create an sspak from it and overwrite the current ArchiveFile with it's contents.
validTargetEnvironments ( ) : ArrayList Finds all environments within this project where the archive can be moved to.
validateArchiveContents ( string | null $mode = null ) : ValidationResult Validate that an sspak contains the correct content.

Описание методов

FileSize() публичный Метод

Calculates and returns a human-readable size of this archive file. If the file exists, it will determine whether to display the output in bytes, kilobytes, megabytes, or gigabytes.
public FileSize ( ) : string
Результат string The human-readable size of this archive file

attachFile() публичный Метод

Does the job of creating a {@link File} record, and setting correct paths into the assets directory.
public attachFile ( string $sspakFilepath, DNDataTransfer $dataTransfer ) : boolean
$sspakFilepath string
$dataTransfer DNDataTransfer
Результат boolean

canDelete() публичный Метод

Whether a {@link Member} can delete this archive from staging area.
public canDelete ( Member | null $member = null ) : boolean
$member Member | null The {@link Member} object to test against.
Результат boolean if $member (or the currently logged in member if null) can delete this archive

canDownload() публичный Метод

This only needs to be checked *once* per member and environment.
public canDownload ( Member | null $member = null ) : true
$member Member | null The {@link Member} object to test against.
Результат true if $member (or the currently logged in member if null) can download this archive

canMoveTo() публичный Метод

Check if this member can move archive into the environment.
public canMoveTo ( DNEnvironment $targetEnv, Member | null $member = null ) : boolean
$targetEnv DNEnvironment Environment to check.
$member Member | null The {@link Member} object to test against. If null, uses Member::currentMember();
Результат boolean true if $member can upload archives linked to this environment, false if they can't.

canRestore() публичный Метод

This only needs to be checked *once* per member and environment.
public canRestore ( Member | null $member = null ) : true
$member Member | null The {@link Member} object to test against.
Результат true if $member (or the currently logged in member if null) can upload this archive

canView() публичный Метод

Inferred from both restore and backup permissions.
public canView ( Member | null $member = null )
$member Member | null The {@link Member} object to test against.

extractArchive() публичный Метод

This also extracts the assets and database and puts them into /database.sql and /assets, respectively.
public extractArchive ( string | null $workingDir = null ) : boolean
$workingDir string | null The path to extract to
Результат boolean

fixArchivePermissions() публичный Метод

Normally, command line tar will use permissions found in the archive, but will substract the user's umask from them. This has a potential to create unreadable files, e.g. cygwin on Windows will pack files with mode 000, hence why this fix is necessary.
public fixArchivePermissions ( string | null $workingDir ) : boolean
$workingDir string | null The path of where the sspak has been extracted to
Результат boolean

generateFilename() публичный Метод

Returns a unique filename, including project/environment/timestamp details.
public generateFilename ( DNDataTransfer $dataTransfer ) : string
$dataTransfer DNDataTransfer
Результат string

generateFilepath() публичный Метод

Does not create the path on the filesystem. Can be used to store files related to this transfer.
public generateFilepath ( DNDataTransfer $dataTransfer ) : string
$dataTransfer DNDataTransfer
Результат string Absolute file path

generate_upload_token() публичный статический Метод

Returns a unique token to correlate an offline item (posted DVD) with a specific archive placeholder.
public static generate_upload_token ( $chars = 8 ) : string
Результат string

getCMSFields() публичный Метод

public getCMSFields ( )

getDefaultSearchContext() публичный Метод

getModeNice() публичный Метод

public getModeNice ( )

get_mode_map() публичный статический Метод

public static get_mode_map ( )

isPending() публичный Метод

Some archives don't have files attached to them yet, because a file has been posted offline and is waiting to be uploaded against this "archive placeholder".
public isPending ( ) : boolean
Результат boolean

onAfterDelete() публичный Метод

public onAfterDelete ( )

onBeforeWrite() публичный Метод

public onBeforeWrite ( )

setArchiveFromFiles() публичный Метод

Use GZIP=-1 for less compression on assets, which are already heavily compressed to begin with.
public setArchiveFromFiles ( string | null $workingDir ) : boolean
$workingDir string | null The path of where the sspak has been extracted to
Результат boolean

validTargetEnvironments() публичный Метод

Excludes current environment automatically.
public validTargetEnvironments ( ) : ArrayList
Результат ArrayList List of valid environments.

validateArchiveContents() публичный Метод

For example, if the user uploaded an sspak containing just the db, but declared in the form that it contained db+assets, then the archive is not valid.
public validateArchiveContents ( string | null $mode = null ) : ValidationResult
$mode string | null "db", "assets", or "all". This is the content we're checking for. Default to the archive setting
Результат ValidationResult