DumpCommands
extends AbstractCommands
in package
Provides commands to download and install dump files.
Table of Contents
Methods
- getConfigurationFile() : string
- Path to YAML configuration file containing command defaults.
- getJson() : array<string|int, mixed>
- Returns the JSON parsed content.
- getWorkingDir() : string
- Returns the current working directory.
- isWebsiteInstalled() : bool
- Check if the website is installed.
- toolkitCreateDump() : CollectionBuilder|int
- Export the local snapshot.
- toolkitDownloadDump() : int
- Download database snapshot.
- toolkitInstallDump() : CollectionBuilder|int
- Import the production snapshot.
- getBin() : string
- Validate and return the path to given bin.
- getBinPath() : string
- Return the path to given bin.
- getConfigValue() : mixed|null
- Return the configuration value.
- getNodeBin() : string
- Validate and return the path to given bin from node packages.
- getNodeBinPath() : string
- Return the path to given bin from node packages.
- isJunit() : bool
- Check whether Junit option is being used, or env var is set.
- isSimulating() : bool
- Check if current command is being executed with option simulate.
- taskExecute() : CollectionBuilder
- Execute a command.
- taskProcess() : ReplaceBlock|CollectionBuilder
- Process the file.
- taskReplaceBlock() : ReplaceBlock|CollectionBuilder
- Replace block in a file.
- addAuthToUrl() : string
- Prepare given URL to include the user and pass/token.
- asdaProcessFile() : array<string|int, mixed>
- Helper to download and process a Nextcloud dump file.
- customCheckNewerDump() : bool
- Check if a newer dump exists on the Custom server.
- customDownloadDump() : int
- Download the dumpfile from the custom server.
- getAsdaDate() : string
- Returns a human-readable date of the ASDA dump.
- nextcloudCheckNewerDump() : bool
- Check if a newer dump exists on the Nextcloud server.
- nextcloudDownloadDump() : int|CollectionBuilder
- Download the available services from Nextcloud.
- taskImportDatabase() : ExecStack
- Import given dump file, gunzip is used if dump ends with .gz.
- tmpDirectory() : string
- Return the tmp folder path, folder is created if missing.
- wgetDownloadFile() : Exec
- Download the file present in the tmp file.
- wgetGenerateInputFile() : void
- Create a file containing the url to be used by wget --input-file option.
- wgetGetFileModifiedDate() : string
- Get the modified date from the remote file.
Methods
getConfigurationFile()
Path to YAML configuration file containing command defaults.
public
getConfigurationFile() : string
Return values
string —Configuration file path.
getJson()
Returns the JSON parsed content.
public
getJson(string $filename[, bool $throwException = true ]) : array<string|int, mixed>
Parameters
- $filename : string
- $throwException : bool = true
-
If the file is not found.
Return values
array<string|int, mixed> —Json parsed content.
getWorkingDir()
Returns the current working directory.
public
getWorkingDir() : string
Return values
string —The current working directory.
isWebsiteInstalled()
Check if the website is installed.
public
isWebsiteInstalled() : bool
Return values
booltoolkitCreateDump()
Export the local snapshot.
public
toolkitCreateDump(ConsoleIO $io[, array<string|int, mixed> $options = ['dumpfile' => InputOption::VALUE_REQUIRED] ]) : CollectionBuilder|int
This command should be only used with the corporate docker image fpfis/httpd-php.
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['dumpfile' => InputOption::VALUE_REQUIRED]
-
Command options.
Tags
Return values
CollectionBuilder|int —Collection builder.
toolkitDownloadDump()
Download database snapshot.
public
toolkitDownloadDump(ConsoleIO $io[, array<string|int, mixed> $options = ['is-admin' => InputOption::VALUE_NONE, 'yes' => InputOption::VALUE_NONE] ]) : int
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['is-admin' => InputOption::VALUE_NONE, 'yes' => InputOption::VALUE_NONE]
-
Command options.
Tags
Return values
int —The toolkit download file status.
toolkitInstallDump()
Import the production snapshot.
public
toolkitInstallDump(ConsoleIO $io[, array<string|int, mixed> $options = ['dumpfile' => InputOption::VALUE_REQUIRED, 'myloader' => InputOption::VALUE_NONE] ]) : CollectionBuilder|int
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['dumpfile' => InputOption::VALUE_REQUIRED, 'myloader' => InputOption::VALUE_NONE]
-
Command options.
Tags
Return values
CollectionBuilder|int —Collection builder.
getBin()
Validate and return the path to given bin.
protected
getBin(string $name) : string
Parameters
- $name : string
-
The bin to look for.
Tags
Return values
string —The bin path.
getBinPath()
Return the path to given bin.
protected
getBinPath(string $name) : string
Parameters
- $name : string
Return values
string —The path to given binary.
getConfigValue()
Return the configuration value.
protected
getConfigValue(string $key[, mixed|null $default = null ]) : mixed|null
Parameters
- $key : string
-
The config item to look up.
- $default : mixed|null = null
-
Default configuration value for the key item if neither has value nor exists.
Return values
mixed|null —The configuration value.
getNodeBin()
Validate and return the path to given bin from node packages.
protected
getNodeBin(string $name) : string
Parameters
- $name : string
-
The bin to look for.
Tags
Return values
string —The bin path.
getNodeBinPath()
Return the path to given bin from node packages.
protected
getNodeBinPath(string $name) : string
Parameters
- $name : string
Return values
string —The path to given binary.
isJunit()
Check whether Junit option is being used, or env var is set.
protected
isJunit() : bool
Return values
boolisSimulating()
Check if current command is being executed with option simulate.
protected
isSimulating() : bool
Return values
bool —True if using --simulate, false otherwise.
taskExecute()
Execute a command.
protected
taskExecute(array<string|int, string> $tasks) : CollectionBuilder
Parameters
- $tasks : array<string|int, string>
-
An array with tasks to execute.
Return values
CollectionBuilder —The task executed.
taskProcess()
Process the file.
protected
taskProcess(string $source[, string $destination = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
- $source : string
-
The source file to process.
- $destination : string = ''
-
The destination file.
Return values
ReplaceBlock|CollectionBuilder —The file task processed.
taskReplaceBlock()
Replace block in a file.
protected
taskReplaceBlock([string $filename = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
- $filename : string = ''
-
The file to process.
Return values
ReplaceBlock|CollectionBuilder —The file replaced.
addAuthToUrl()
Prepare given URL to include the user and pass/token.
private
addAuthToUrl(string $url, string $user, string $pass) : string
Parameters
- $url : string
-
The URL to process.
- $user : string
-
The user to be added to the URL.
- $pass : string
-
The password or token to be added to the URL.
Return values
stringasdaProcessFile()
Helper to download and process a Nextcloud dump file.
private
asdaProcessFile(string $link, string $service) : array<string|int, mixed>
Parameters
- $link : string
-
The link to the folder.
- $service : string
-
The service to use.
Return values
array<string|int, mixed> —The tasks to execute.
customCheckNewerDump()
Check if a newer dump exists on the Custom server.
private
customCheckNewerDump(string $tmpFile, string $dumpfile) : bool
Parameters
- $tmpFile : string
-
The tmp file containing the url for the remote file.
- $dumpfile : string
-
The local dumpfile.
Return values
bool —Return true if the modified date is different between local and remote dumps, False is case of error or no local file exists.
customDownloadDump()
Download the dumpfile from the custom server.
private
customDownloadDump(ConsoleIO $io, array<string|int, mixed> $options) : int
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed>
-
Command options.
Return values
int —The file download from custom server status.
getAsdaDate()
Returns a human-readable date of the ASDA dump.
private
getAsdaDate(string $filename) : string
Parameters
- $filename : string
-
The dump filename that contains the date.
Return values
string —The formatted date, fallback to filename if no date is found.
nextcloudCheckNewerDump()
Check if a newer dump exists on the Nextcloud server.
private
nextcloudCheckNewerDump(string $link, string $service) : bool
Parameters
- $link : string
-
The link to the folder.
- $service : string
-
The service to use.
Return values
bool —Return true if sha1 from local is different from the server, False is case of error or no local file exists.
nextcloudDownloadDump()
Download the available services from Nextcloud.
private
nextcloudDownloadDump(ConsoleIO $io, array<string|int, mixed> $options) : int|CollectionBuilder
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed>
-
Command options.
Tags
Return values
int|CollectionBuilder —The service download from Nextcloud task.
taskImportDatabase()
Import given dump file, gunzip is used if dump ends with .gz.
private
taskImportDatabase(string $dump) : ExecStack
Parameters
- $dump : string
-
The path to the dump file.
Tags
Return values
ExecStack —The file imported task.
tmpDirectory()
Return the tmp folder path, folder is created if missing.
private
tmpDirectory() : string
Return values
string —The tmp folder path.
wgetDownloadFile()
Download the file present in the tmp file.
private
wgetDownloadFile(string $tmp, string $destination[, string|null $accept = null ][, bool $silent = false ]) : Exec
Parameters
- $tmp : string
-
The temporary filename.
- $destination : string
-
The destination filename.
- $accept : string|null = null
-
A comma-separated list of accepted extensions.
- $silent : bool = false
-
Whether show or not output from task.
Return values
Exec —The file downloaded task.
wgetGenerateInputFile()
Create a file containing the url to be used by wget --input-file option.
private
wgetGenerateInputFile(string $url, string $tmp[, bool $silent = false ]) : void
Parameters
- $url : string
-
Url to fill in the temp file.
- $tmp : string
-
The temporary filename.
- $silent : bool = false
-
Whether show or not output from task.
Return values
void —The file.
wgetGetFileModifiedDate()
Get the modified date from the remote file.
private
wgetGetFileModifiedDate(string $tmp) : string
Parameters
- $tmp : string
-
The temporary filename.
Return values
string —The file modified by date.