VersionManager
Version manager
class System\Classes\VersionManager
Manages the versions and database updates for plugins.
Traits
Trait | Description |
---|---|
Singleton
|
Singleton trait. |
Constants
Constant | Type | Value | Description |
---|---|---|---|
HISTORY_TYPE_COMMENT
|
string |
"comment"
|
string
"comment"
Morph types for history table. |
HISTORY_TYPE_SCRIPT
|
string |
"script"
|
string
"script"
|
NO_VERSION_VALUE
|
integer |
0
|
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.
Property | Type | Description |
---|---|---|
$plugin | string | PluginBase |
string | PluginBase
Either the identifier of a plugin as a string, or a Plugin class. |
public getCurrentVersionNote (string | PluginBase $plugin) : string
Get last version note
Property | Type | Description |
---|---|---|
$plugin | string | PluginBase |
string | PluginBase
|
public getDatabaseHistory ($code)
Returns all the update history for a plugin.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
public hasDatabaseVersion (string | PluginBase $plugin, string $version) : bool
Check if a certain version of the plugin exists in the plugin history database.
Property | Type | Description |
---|---|---|
$plugin | string | PluginBase |
string | PluginBase
Either the identifier of a plugin as a string, or a Plugin class. |
$version | string |
string
|
public listNewVersions ($plugin)
Returns a list of unapplied plugin versions.
Property | Type | Description |
---|---|---|
$plugin | mixed |
mixed
|
public purgePlugin (string $pluginCode) : void
Deletes all records from the version and history tables for a plugin.
Property | Type | Description |
---|---|---|
$pluginCode | string |
string
Plugin code |
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.
Property | Type | Description |
---|---|---|
$plugin | mixed |
mixed
Either the identifier of a plugin as a string, or a Plugin class. |
$stopOnVersion | string |
string
|
$stopCurrentVersion | boolean |
boolean
|
public replacePlugin (System\Classes\PluginBase $plugin, string $replace)
Update the current replaced plugin's version to reference the replacing plugin.
Property | Type | Description |
---|---|---|
$plugin | System\Classes\PluginBase |
System\Classes\PluginBase
|
$replace | string |
string
|
public setNotesOutput (Illuminate\Console\Command $output) : self
Sets an output stream for writing notes.
Property | Type | Description |
---|---|---|
$output | Illuminate\Console\Command |
Illuminate\Console\Command
|
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.
Property | Type | Description |
---|---|---|
$plugin | mixed |
mixed
|
$stopAfterVersion | mixed |
mixed
|
protected applyDatabaseComment ($code, $version, $comment)
Registers a database update comment in the history table.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
$comment | mixed |
mixed
|
protected applyDatabaseScript ($code, $version, $script)
Registers a database update script in the history table.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
$script | mixed |
mixed
|
protected applyPluginUpdate ($code, $version, $details)
Applies a single version update to a plugin.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
$details | mixed |
mixed
|
protected extractScriptsAndComments ($details) : array
Extract script and comments from version details
Property | Type | Description |
---|---|---|
$details | mixed |
mixed
|
protected getDatabaseVersion ($code)
Returns the latest version of a plugin from the database.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
protected getFileVersions ($code)
Returns all versions of a plugin from its version file.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
protected getLastHistory (string $code) : stdClass | null
Returns the last update history for a plugin.
Property | Type | Description |
---|---|---|
$code | string |
string
The plugin identifier |
protected getLatestFileVersion ($code)
Returns the latest version of a plugin from its version file.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
protected
getNewFileVersions ($code, $version = null
)
Returns any new versions from a supplied version, ie. unapplied versions.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
protected
getOldFileVersions ($code, $version = null
)
Returns older versions up to a supplied version, ie. applied versions.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
protected getVersionFile ($code)
Returns the absolute path to a version file for a plugin.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
protected
hasDatabaseHistory ($code, $version, $script = null
)
Checks if a plugin has an applied update version.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
$script | mixed |
mixed
|
protected hasVersionFile ($code)
Checks if a plugin has a version file.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
protected init ()
protected normalizeVersion (string $version) : string
Normalize a version identifier by removing the optional 'v' prefix
Property | Type | Description |
---|---|---|
$version | string |
string
|
protected
out (string $message, boolean $newline = false
)
: static
Writes output to the console.
Property | Type | Description |
---|---|---|
$message | string |
string
|
$newline | boolean |
boolean
|
protected removeDatabaseComment ($code, $version)
Removes a database update comment in the history table.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
protected removeDatabaseScript ($code, $version, $script)
Removes a database update script in the history table.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
$script | mixed |
mixed
|
protected
setDatabaseVersion ($code, $version = null
)
Updates a plugin version in the database.
Property | Type | Description |
---|---|---|
$code | mixed |
mixed
|
$version | mixed |
mixed
|
protected write (Illuminate\Console\View\Components\Component $component, array $arguments) : static
Writes output to the console using a Laravel CLI View component.
Property | Type | Description |
---|---|---|
$component | Illuminate\Console\View\Components\Component |
Illuminate\Console\View\Components\Component
|
$arguments | array |
array
|
inherited public __clone ()
inherited public __wakeup ()
inherited
public
static
final
forgetInstance ($container = null
)
: void
Forget this singleton's instance if it exists
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited
public
static
final
instance ($container = null
)
: static
Create a new instance of this singleton.
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited protected final __construct ()
Constructor.