pm_Hook_Backup_Transport
in package
implements
pm_Hook_Backup
Hook for backup transport, e.g. backup to cloud
Tags
Interfaces, Classes and Traits
- pm_Hook_Backup
- Interface for backup and restore hooks
Table of Contents
- TYPE_CUSTOMER = 'customer'
- TYPE_RESELLER = 'reseller'
- TYPE_SERVER = 'server'
- TYPE_SUBSCRIPTION = 'subscription'
- $_objectId : int|null
- $_objectType : string
- One of the constants TYPE_*
- appendFile() : int
- The method appends content of the local file to the file in the external storage.
- authorize() : mixed
- Is called just before show subform provided by getSettingsSubForm. This method may be used for OAuth2 authorization.
- check() : array<string|int, mixed>
- Checks connection with the storage and reports problems ['errors' => ['message', ...], 'warnings' => ['message', ...]].
- closeFile() : mixed
- Closes file.
- createDir() : mixed
- Creates the specified directory.
- deleteDir() : mixed
- Removes the specified directory.
- deleteFile() : mixed
- Removes the specified file.
- getDescription() : string
- Describes this extension for backup manager UI. The description should include storage name, internal path, etc.
- getHash() : array<string|int, mixed>
- Returns an array with information about hash values that the extension returns for files. If the extension is not configured to return hash values or cannot provide them an empty array should be returned.
- getQuota() : array<string|int, mixed>
- Returns array with information about user disk quota in bytes. If the storage cannot provide information about quota an empty array should be returned.
- getSettingsSubForm() : pm_Form_SubForm
- Returns subform with storage settings.
- init() : mixed
- Initializes an object of the class. The method should be called explicitly within an overridden method.
- isConfigured() : bool
- Returns true if the extension is configured for the object.
- listDir() : array<string|int, mixed>
- Returns array [['name' => ..., 'size' => ..., 'isDir' => ...], ...].
- openFileRead() : mixed
- Prepare a file with the specified name on the storage to read from the specified offset.
- openFileWrite() : mixed
- Prepares the storage to write a new file with the specified name.
- readFile() : int
- Reads file content to the local file.
- stat() : null|array<string|int, mixed>
- Returns array ['name' => ..., 'size' => ..., 'isDir' => ...].
Constants
TYPE_CUSTOMER
public
mixed
TYPE_CUSTOMER
= 'customer'
TYPE_RESELLER
public
mixed
TYPE_RESELLER
= 'reseller'
TYPE_SERVER
public
mixed
TYPE_SERVER
= 'server'
TYPE_SUBSCRIPTION
public
mixed
TYPE_SUBSCRIPTION
= 'subscription'
Properties
$_objectId
protected
int|null
$_objectId
$_objectType
One of the constants TYPE_*
protected
string
$_objectType
Methods
appendFile()
The method appends content of the local file to the file in the external storage.
public
appendFile(mixed $fd, string $localFile) : int
Override this method in the extension class. Default implementation returns 0.
Parameters
- $fd : mixed
-
descriptor returned by openFileWrite
- $localFile : string
Return values
int —Bytes written
authorize()
Is called just before show subform provided by getSettingsSubForm. This method may be used for OAuth2 authorization.
public
authorize( $controller) : mixed
The method may be overridden in extension class. Default implementation does nothing.
Parameters
Return values
mixed —check()
Checks connection with the storage and reports problems ['errors' => ['message', ...], 'warnings' => ['message', ...]].
public
check() : array<string|int, mixed>
The method may be overridden in extension class. Default implementation returns empty array.
Return values
array<string|int, mixed> —closeFile()
Closes file.
public
closeFile(mixed $fd) : mixed
Override this method in the extension class. Default implementation does nothing.
Parameters
- $fd : mixed
-
descriptor returned by openFileWrite or openFileRead
Return values
mixed —createDir()
Creates the specified directory.
public
createDir(string $path) : mixed
Override this method in the extension class. Default implementation does nothing.
Parameters
- $path : string
Return values
mixed —deleteDir()
Removes the specified directory.
public
deleteDir(string $path) : mixed
Override this method in the extension class. Default implementation does nothing.
Parameters
- $path : string
Return values
mixed —deleteFile()
Removes the specified file.
public
deleteFile(string $path) : mixed
Override this method in the extension class. Default implementation does nothing.
Parameters
- $path : string
Return values
mixed —getDescription()
Describes this extension for backup manager UI. The description should include storage name, internal path, etc.
public
getDescription() : string
The method may be overridden in extension class. Default implementation returns extension's display name.
Return values
string —getHash()
Returns an array with information about hash values that the extension returns for files. If the extension is not configured to return hash values or cannot provide them an empty array should be returned.
public
getHash() : array<string|int, mixed>
Example ['type' => 'md5', 'blockSize' => 0] If the extension defines the hash it should return it via stat() method or may return it via listDir() method. Hash values should be returned via 'hash' key and should be scalar if blockSize = 0 or array if blockSize != 0. Hash values are used for verify content of backup files right after creation. Supported hash types: md5, sha1, sha256, quickXor The method may be overridden in extension class. Default implementation returns an empty array.
Tags
Return values
array<string|int, mixed> —getQuota()
Returns array with information about user disk quota in bytes. If the storage cannot provide information about quota an empty array should be returned.
public
getQuota() : array<string|int, mixed>
Example ['total' => 5368709120, 'free' => 3221225472] The method may be overridden in extension class. Default implementation returns empty array.
Return values
array<string|int, mixed> —getSettingsSubForm()
Returns subform with storage settings.
public
getSettingsSubForm() : pm_Form_SubForm
Override this method in the extension class. Default implementation empty an instance of pm_Form_SubForm.
Return values
pm_Form_SubForm —init()
Initializes an object of the class. The method should be called explicitly within an overridden method.
public
init(string $objectType, int|null $objectId) : mixed
Parameters
- $objectType : string
-
(server, reseller, customer, subscription)
- $objectId : int|null
Return values
mixed —isConfigured()
Returns true if the extension is configured for the object.
public
isConfigured() : bool
Override this method in the extension class. Default implementation returns false.
Return values
bool —listDir()
Returns array [['name' => ..., 'size' => ..., 'isDir' => ...], ...].
public
listDir( $path) : array<string|int, mixed>
Override this method in the extension class. Default implementation returns empty array.
Parameters
Return values
array<string|int, mixed> —openFileRead()
Prepare a file with the specified name on the storage to read from the specified offset.
public
openFileRead(string $path, int $offset) : mixed
Override this method in the extension class. Default implementation returns empty string.
Parameters
- $path : string
- $offset : int
Return values
mixed —Returns file descriptor for readFile
openFileWrite()
Prepares the storage to write a new file with the specified name.
public
openFileWrite(string $path) : mixed
The method returns handle which should be used in appendFile and closeFile methods. Override this method in the extension class. Default implementation returns empty string.
Parameters
- $path : string
Return values
mixed —File descriptor
readFile()
Reads file content to the local file.
public
readFile(mixed $fd, string $localFile[, int|null $size = null ]) : int
Override this method in the extension class. Default implementation returns 0.
Parameters
- $fd : mixed
-
descriptor returned by openFileRead method
- $localFile : string
- $size : int|null = null
-
if the size is null the whole file should be read
Return values
int —Bytes read
stat()
Returns array ['name' => ..., 'size' => ..., 'isDir' => ...].
public
stat(string $path) : null|array<string|int, mixed>
Override this method in the extension class. Default implementation returns null.
Parameters
- $path : string