VersionManager

Version manager

 class System\Classes\VersionManager

Manages the versions and database updates for plugins.

Traits

Trait Description
Singleton

Singleton trait.

Constants

Constant Description
HISTORY_TYPE_COMMENT
string "comment"

Morph types for history table.

HISTORY_TYPE_SCRIPT
string "script"
NO_VERSION_VALUE
integer 0

Value when no updates are found.

Properties

protected $databaseHistory : mixed

Cache of database history

protected $databaseVersions : mixed

Cache of database versions

protected $fileVersions : mixed

Cache of plugin versions as files.

protected $notesOutput : Illuminate\Console\OutputStyle

protected $pluginManager : System\Classes\PluginManager

protected $updater : Winter\Storm\Database\Updater

Methods

public getCurrentVersion (string | PluginBase $plugin) : string

Get the currently installed version of the plugin.

Parameters
Property Description
$plugin
string | PluginBase

Either the identifier of a plugin as a string, or a Plugin class.

Returns
string

public getCurrentVersionNote (string | PluginBase $plugin) : string

Get last version note

Parameters
Property Description
$plugin
string | PluginBase
Returns
string

public getDatabaseHistory ($code)

Returns all the update history for a plugin.

Parameters
Property Description
$code
mixed
Returns
mixed

public hasDatabaseVersion (string | PluginBase $plugin, string $version) : bool

Check if a certain version of the plugin exists in the plugin history database.

Parameters
Property Description
$plugin
string | PluginBase

Either the identifier of a plugin as a string, or a Plugin class.

$version
string
Returns
bool

public listNewVersions ($plugin)

Returns a list of unapplied plugin versions.

Parameters
Property Description
$plugin
mixed
Returns
mixed

public purgePlugin (string $pluginCode) : void

Deletes all records from the version and history tables for a plugin.

Parameters
Property Description
$pluginCode
string

Plugin code

Returns
void

public removePlugin (mixed $plugin, string $stopOnVersion = null, boolean $stopCurrentVersion = false) : bool

Removes and packs down a plugin from the system. Files are left intact.

If the $stopOnVersion parameter is specified, the process stops after the specified version is rolled back.

Parameters
Property Description
$plugin
mixed

Either the identifier of a plugin as a string, or a Plugin class.

$stopOnVersion
string
$stopCurrentVersion
boolean
Returns
bool

public replacePlugin (System\Classes\PluginBase $plugin, string $replace)

Update the current replaced plugin's version to reference the replacing plugin.

Parameters
Property Description
$plugin
System\Classes\PluginBase
$replace
string
Returns
mixed

public setNotesOutput (Illuminate\Console\Command $output) : self

Sets an output stream for writing notes.

Parameters
Property Description
$output
Illuminate\Console\Command
Returns
self

public updatePlugin ($plugin, $stopAfterVersion = null)

Updates a single plugin by its code or object with it's latest changes.

If the $stopAfterVersion parameter is specified, the process stops after the specified version is applied.

Parameters
Property Description
$plugin
mixed
$stopAfterVersion
mixed
Returns
mixed

protected applyDatabaseComment ($code, $version, $comment)

Registers a database update comment in the history table.

Parameters
Property Description
$code
mixed
$version
mixed
$comment
mixed
Returns
mixed

protected applyDatabaseScript ($code, $version, $script)

Registers a database update script in the history table.

Parameters
Property Description
$code
mixed
$version
mixed
$script
mixed
Returns
mixed

protected applyPluginUpdate ($code, $version, $details)

Applies a single version update to a plugin.

Parameters
Property Description
$code
mixed
$version
mixed
$details
mixed
Returns
mixed

protected extractScriptsAndComments ($details) : array

Extract script and comments from version details

Parameters
Property Description
$details
mixed
Returns
array

protected getDatabaseVersion ($code)

Returns the latest version of a plugin from the database.

Parameters
Property Description
$code
mixed
Returns
mixed

protected getFileVersions ($code)

Returns all versions of a plugin from its version file.

Parameters
Property Description
$code
mixed
Returns
mixed

protected getLastHistory (string $code) : stdClass | null

Returns the last update history for a plugin.

Parameters
Property Description
$code
string

The plugin identifier

Returns
stdClass | null

protected getLatestFileVersion ($code)

Returns the latest version of a plugin from its version file.

Parameters
Property Description
$code
mixed
Returns
mixed

protected getNewFileVersions ($code, $version = null)

Returns any new versions from a supplied version, ie. unapplied versions.

Parameters
Property Description
$code
mixed
$version
mixed
Returns
mixed

protected getOldFileVersions ($code, $version = null)

Returns older versions up to a supplied version, ie. applied versions.

Parameters
Property Description
$code
mixed
$version
mixed
Returns
mixed

protected getVersionFile ($code)

Returns the absolute path to a version file for a plugin.

Parameters
Property Description
$code
mixed
Returns
mixed

protected hasDatabaseHistory ($code, $version, $script = null)

Checks if a plugin has an applied update version.

Parameters
Property Description
$code
mixed
$version
mixed
$script
mixed
Returns
mixed

protected hasVersionFile ($code)

Checks if a plugin has a version file.

Parameters
Property Description
$code
mixed
Returns
mixed

protected init ()

Returns
mixed

protected normalizeVersion (string $version) : string

Normalize a version identifier by removing the optional 'v' prefix

Parameters
Property Description
$version
string
Returns
string

protected out (string $message, boolean $newline = false) : static

Writes output to the console.

Parameters
Property Description
$message
string
$newline
boolean
Returns
static

protected removeDatabaseComment ($code, $version)

Removes a database update comment in the history table.

Parameters
Property Description
$code
mixed
$version
mixed
Returns
mixed

protected removeDatabaseScript ($code, $version, $script)

Removes a database update script in the history table.

Parameters
Property Description
$code
mixed
$version
mixed
$script
mixed
Returns
mixed

protected setDatabaseVersion ($code, $version = null)

Updates a plugin version in the database.

Parameters
Property Description
$code
mixed
$version
mixed
Returns
mixed

protected write (Illuminate\Console\View\Components\Component $component, array $arguments) : static

Writes output to the console using a Laravel CLI View component.

Parameters
Property Description
$component
Illuminate\Console\View\Components\Component
$arguments
array
Returns
static

public __clone ()

Inherited from Singleton
Returns
mixed

public __wakeup ()

Inherited from Singleton
Returns
mixed

public static final forgetInstance ($container = null) : void

Inherited from Singleton

Forget this singleton's instance if it exists

Parameters
Property Description
$container
mixed
Returns
void

public static final instance ($container = null) : static

Inherited from Singleton

Create a new instance of this singleton.

Parameters
Property Description
$container
mixed
Returns
static

protected final __construct ()

Inherited from Singleton

Constructor.

Returns
mixed
Copyright © 2023 Winter CMS