UpgradeScript
    
            
            in package
            
        
    
    
    
Used for abstracting common tasks done during upgrades.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
 - get() : UpgradeScript|null
 - Get instance of UpgradeScript for a specific NamelessMC version, null if it doesn't exist.
 - run() : void
 - Execute this UpgradeScript.
 - databaseQueries() : array<string|int, mixed>
 - Run multiple queries.
 - databaseQuery() : mixed
 - Run a single database query.
 - deleteFiles() : void
 - Delete a single folder or file.
 - deleteFilesInPath() : void
 - Delete one or more folders or files in a path.
 - log() : void
 - Logs a message to the screen and the warning-log.log file.
 - runMigrations() : void
 - Execute any pending database migrations.
 - setVersion() : void
 - Update the version of this NamelessMC website in the database.
 
Properties
$_cache
    protected
        Cache
    $_cache
    
    
    
    
    
Methods
__construct()
    public
                    __construct() : mixed
    get()
Get instance of UpgradeScript for a specific NamelessMC version, null if it doesn't exist.
    public
            static        get(string $current_version) : UpgradeScript|null
    Parameters
- $current_version : string
 - 
                    
Current NamelessMC version (ie:
2.0.0-pr12,2.0.0) 
Return values
UpgradeScript|null —Instance of UpgradeScript from file
run()
Execute this UpgradeScript.
    public
    abstract                run() : void
    databaseQueries()
Run multiple queries.
    protected
                    databaseQueries(array<string|int, Closure> $queries) : array<string|int, mixed>
    Parameters
- $queries : array<string|int, Closure>
 - 
                    
Array of queries to execute one after another
 
Return values
array<string|int, mixed> —Results from queries in order
databaseQuery()
Run a single database query.
    protected
                    databaseQuery(Closure $query) : mixed
    Parameters
- $query : Closure
 - 
                    
Function which returns the query
 
Return values
mixed —The result of the closure, if any
deleteFiles()
Delete a single folder or file.
    protected
                    deleteFiles(string|array<string|int, mixed> $paths) : void
    Parameters
- $paths : string|array<string|int, mixed>
 - 
                    
Path to folder or file to delete
 
deleteFilesInPath()
Delete one or more folders or files in a path.
    protected
                    deleteFilesInPath(string $path, array<string|int, mixed> $files[, bool $recursive = false ]) : void
    Parameters
- $path : string
 - 
                    
Prefix path to append to each of the files in
$filesarray - $files : array<string|int, mixed>
 - 
                    
Name of folders/files in
$pathto delete. Use*for all folders/files - $recursive : bool = false
 - 
                    
Whether to recursively delete
 
log()
Logs a message to the screen and the warning-log.log file.
    protected
                    log(string $message) : void
    Parameters
- $message : string
 - 
                    
Message to log
 
runMigrations()
Execute any pending database migrations.
    protected
                    runMigrations() : void
    setVersion()
Update the version of this NamelessMC website in the database.
    protected
                    setVersion(string $version) : void
    Parameters
- $version : string
 - 
                    
Version to set