- Full name:
\App\Infrastructure\Services\Updater - This class is marked as final and can't be subclassed
- This class is a Final class
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
NO_UPDATE_AVAILABLE |
public | 0 | |
ERROR_VERSION_CHECK |
public | 20 | |
ERROR_TEMP_DIR |
public | 30 | |
ERROR_INSTALL_DIR |
public | 35 | |
ERROR_DOWNLOAD_UPDATE |
public | 40 | |
ERROR_DELETE_TEMP_UPDATE |
public | 50 | |
ERROR_SIMULATE |
public | 70 |
Properties
latestVersion
updates
cache
log
simulationResults
tempDir
installDir
branch
username
password
onEachUpdateFinishCallbacks
onAllUpdateFinishCallbacks
sslVerifyHost
updateUrl
updateFile
currentVersion
dirPermissions
updateScriptName
cacheTtl
Methods
__construct
Create new instance
public __construct(string|null $tempDir = null, string|null $installDir = null, int $maxExecutionTime = 60): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$tempDir |
string|null | |
$installDir |
string|null | |
$maxExecutionTime |
int |
Throws:
setTempDir
Set the temporary download directory.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$dir |
string |
setInstallDir
Set the installation directory.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$dir |
string |
setUpdateFile
Set the update filename.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updateFile |
string |
setUpdateUrl
Set the update filename.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updateUrl |
string |
setBranch
Set the update branch.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$branch |
string | branch |
setCache
Set the cache component.
public setCache(\Psr\SimpleCache\CacheInterface $adapter, int $ttl): \App\Infrastructure\Services\Updater
Parameters:
| Parameter | Type | Description |
|---|---|---|
$adapter |
\Psr\SimpleCache\CacheInterface | |
$ttl |
int |
setCurrentVersion
Set the version of the current installed software.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$currentVersion |
string |
setBasicAuth
Set username and password for basic authentication.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$username |
string | |
$password |
string |
useBasicAuth
Set authentication header if username and password exist.
setLogger
Replace the logger internally used by the given logger instance.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$logger |
\Psr\Log\LoggerInterface |
getVersionsToUpdate
Get an array of versions which will be installed.
getSslVerifyHost
setSslVerifyHost
Parameters:
| Parameter | Type | Description |
|---|---|---|
$sslVerifyHost |
bool |
checkUpdate
Check for a new version
Parameters:
| Parameter | Type | Description |
|---|---|---|
$timeout |
int | Download timeout in seconds (Only applied for downloads via curl) |
Return Value:
true: New version is available false: Error while checking for update int: Status code (i.e. Updater::NO_UPDATE_AVAILABLE)
Throws:
newVersionAvailable
Check if a new version is available.
isValidUrl
Check if url is valid.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$url |
string |
downloadCurl
Download file via curl.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$url |
string | URL to file |
$timeout |
int |
downloadUpdate
Download the update
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updateUrl |
string | Url where to download from |
$updateFile |
string | Path where to save the download |
Throws:
simulateInstall
Simulate update process.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updateFile |
string |
install
Install update.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updateFile |
string | Path to the update file |
$simulateInstall |
int|bool | Check for directory and file permissions instead of installing the update |
$version |
string |
update
Update to the latest version
Parameters:
| Parameter | Type | Description |
|---|---|---|
$simulateInstall |
bool | Check for directory and file permissions before copying files (Default: true) |
$deleteDownload |
bool | Delete download after update (Default: true) |
Throws:
onEachUpdateFinish
Add callback which is executed after each update finished.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$callback |
callable |
setOnAllUpdateFinishCallbacks
Add callback which is executed after all updates finished.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$callback |
callable |
runOnEachUpdateFinishCallbacks
Run callbacks after each update finished.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updateVersion |
string | |
$simulate |
bool |
runOnAllUpdateFinishCallbacks
Run callbacks after all updates finished.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$updatedVersions |
array |