VersionManager
in package
Uses
Singleton
Version manager
Manages the versions and database updates for plugins.
Tags
Table of Contents
- HISTORY_TYPE_COMMENT = 'comment'
- Morph types for history table.
- HISTORY_TYPE_SCRIPT = 'script'
- NO_VERSION_VALUE = 0
- Value when no updates are found.
- $databaseHistory : mixed
- Cache of database history
- $databaseVersions : mixed
- Cache of database versions
- $fileVersions : mixed
- Cache of plugin versions as files.
- $instance : mixed
- $notes : array<string|int, mixed>
- The notes for the current operation.
- $notesOutput : OutputStyle
- $pluginManager : PluginManager
- $updater : Updater
- __clone() : mixed
- __wakeup() : mixed
- forgetInstance() : mixed
- Forget this singleton's instance if it exists
- getCurrentVersion() : string
- Get the currently installed version of the plugin.
- getCurrentVersionNote() : string
- Get last version note
- getNotes() : array<string|int, mixed>
- Get the notes for the last operation.
- hasDatabaseVersion() : bool
- Check if a certain version of the plugin exists in the plugin history database.
- instance() : mixed
- Create a new instance of this singleton.
- listNewVersions() : mixed
- Returns a list of unapplied plugin versions.
- purgePlugin() : void
- Deletes all records from the version and history tables for a plugin.
- removePlugin() : bool
- Removes and packs down a plugin from the system. Files are left intact.
- resetNotes() : self
- Resets the notes store.
- setNotesOutput() : self
- Sets an output stream for writing notes.
- updatePlugin() : mixed
- Updates a single plugin by its code or object with it's latest changes.
- __construct() : mixed
- Constructor.
- applyDatabaseComment() : mixed
- Registers a database update comment in the history table.
- applyDatabaseScript() : mixed
- Registers a database update script in the history table.
- applyPluginUpdate() : mixed
- Applies a single version update to a plugin.
- extractScriptsAndComments() : array<string|int, mixed>
- getDatabaseHistory() : mixed
- Returns all the update history for a plugin.
- getDatabaseVersion() : mixed
- Returns the latest version of a plugin from the database.
- getFileVersions() : mixed
- Returns all versions of a plugin from its version file.
- getLastHistory() : stdClass|null
- Returns the last update history for a plugin.
- getLatestFileVersion() : mixed
- Returns the latest version of a plugin from its version file.
- getNewFileVersions() : mixed
- Returns any new versions from a supplied version, ie. unapplied versions.
- getVersionFile() : mixed
- Returns the absolute path to a version file for a plugin.
- hasDatabaseHistory() : mixed
- Checks if a plugin has an applied update version.
- hasVersionFile() : mixed
- Checks if a plugin has a version file.
- init() : mixed
- note() : void
- Raise a note event for the migrator.
- removeDatabaseComment() : mixed
- Removes a database update comment in the history table.
- removeDatabaseScript() : mixed
- Removes a database update script in the history table.
- setDatabaseVersion() : mixed
- Updates a plugin version in the database.
Constants
HISTORY_TYPE_COMMENT
Morph types for history table.
public
mixed
HISTORY_TYPE_COMMENT
= 'comment'
HISTORY_TYPE_SCRIPT
public
mixed
HISTORY_TYPE_SCRIPT
= 'script'
NO_VERSION_VALUE
Value when no updates are found.
public
mixed
NO_VERSION_VALUE
= 0
Properties
$databaseHistory
Cache of database history
protected
mixed
$databaseHistory
$databaseVersions
Cache of database versions
protected
mixed
$databaseVersions
$fileVersions
Cache of plugin versions as files.
protected
mixed
$fileVersions
$instance
protected
static mixed
$instance
$notes
The notes for the current operation.
protected
array<string|int, mixed>
$notes
= []
$notesOutput
protected
OutputStyle
$notesOutput
$pluginManager
protected
PluginManager
$pluginManager
$updater
protected
Updater
$updater
Methods
__clone()
public
__clone() : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —forgetInstance()
Forget this singleton's instance if it exists
public
final static forgetInstance() : mixed
Return values
mixed —getCurrentVersion()
Get the currently installed version of the plugin.
public
getCurrentVersion(string|PluginBase $plugin) : string
Parameters
- $plugin : string|PluginBase
-
Either the identifier of a plugin as a string, or a Plugin class.
Return values
string —getCurrentVersionNote()
Get last version note
public
getCurrentVersionNote(string|PluginBase $plugin) : string
Parameters
- $plugin : string|PluginBase
Return values
string —getNotes()
Get the notes for the last operation.
public
getNotes() : array<string|int, mixed>
Return values
array<string|int, mixed> —hasDatabaseVersion()
Check if a certain version of the plugin exists in the plugin history database.
public
hasDatabaseVersion(string|PluginBase $plugin, string $version) : bool
Parameters
- $plugin : string|PluginBase
-
Either the identifier of a plugin as a string, or a Plugin class.
- $version : string
Return values
bool —instance()
Create a new instance of this singleton.
public
final static instance() : mixed
Return values
mixed —listNewVersions()
Returns a list of unapplied plugin versions.
public
listNewVersions(mixed $plugin) : mixed
Parameters
- $plugin : mixed
Return values
mixed —purgePlugin()
Deletes all records from the version and history tables for a plugin.
public
purgePlugin(string $pluginCode) : void
Parameters
- $pluginCode : string
-
Plugin code
Return values
void —removePlugin()
Removes and packs down a plugin from the system. Files are left intact.
public
removePlugin(mixed $plugin[, string $stopOnVersion = null ][, bool $stopCurrentVersion = false ]) : bool
If the $stopOnVersion parameter is specified, the process stops after the specified version is rolled back.
Parameters
- $plugin : mixed
-
Either the identifier of a plugin as a string, or a Plugin class.
- $stopOnVersion : string = null
- $stopCurrentVersion : bool = false
Return values
bool —resetNotes()
Resets the notes store.
public
resetNotes() : self
Return values
self —setNotesOutput()
Sets an output stream for writing notes.
public
setNotesOutput(Command $output) : self
Parameters
- $output : Command
Return values
self —updatePlugin()
Updates a single plugin by its code or object with it's latest changes.
public
updatePlugin(mixed $plugin[, mixed $stopOnVersion = null ]) : mixed
If the $stopOnVersion parameter is specified, the process stops after the specified version is applied.
Parameters
- $plugin : mixed
- $stopOnVersion : mixed = null
Return values
mixed —__construct()
Constructor.
protected
final __construct() : mixed
Return values
mixed —applyDatabaseComment()
Registers a database update comment in the history table.
protected
applyDatabaseComment(mixed $code, mixed $version, mixed $comment) : mixed
Parameters
- $code : mixed
- $version : mixed
- $comment : mixed
Return values
mixed —applyDatabaseScript()
Registers a database update script in the history table.
protected
applyDatabaseScript(mixed $code, mixed $version, mixed $script) : mixed
Parameters
- $code : mixed
- $version : mixed
- $script : mixed
Return values
mixed —applyPluginUpdate()
Applies a single version update to a plugin.
protected
applyPluginUpdate(mixed $code, mixed $version, mixed $details) : mixed
Parameters
- $code : mixed
- $version : mixed
- $details : mixed
Return values
mixed —extractScriptsAndComments()
protected
extractScriptsAndComments( $details) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —getDatabaseHistory()
Returns all the update history for a plugin.
protected
getDatabaseHistory(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —getDatabaseVersion()
Returns the latest version of a plugin from the database.
protected
getDatabaseVersion(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —getFileVersions()
Returns all versions of a plugin from its version file.
protected
getFileVersions(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —getLastHistory()
Returns the last update history for a plugin.
protected
getLastHistory(string $code) : stdClass|null
Parameters
- $code : string
-
The plugin identifier
Return values
stdClass|null —getLatestFileVersion()
Returns the latest version of a plugin from its version file.
protected
getLatestFileVersion(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —getNewFileVersions()
Returns any new versions from a supplied version, ie. unapplied versions.
protected
getNewFileVersions(mixed $code[, mixed $version = null ]) : mixed
Parameters
- $code : mixed
- $version : mixed = null
Return values
mixed —getVersionFile()
Returns the absolute path to a version file for a plugin.
protected
getVersionFile(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —hasDatabaseHistory()
Checks if a plugin has an applied update version.
protected
hasDatabaseHistory(mixed $code, mixed $version[, mixed $script = null ]) : mixed
Parameters
- $code : mixed
- $version : mixed
- $script : mixed = null
Return values
mixed —hasVersionFile()
Checks if a plugin has a version file.
protected
hasVersionFile(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —init()
protected
init() : mixed
Return values
mixed —note()
Raise a note event for the migrator.
protected
note(string $message) : void
Parameters
- $message : string
Return values
void —removeDatabaseComment()
Removes a database update comment in the history table.
protected
removeDatabaseComment(mixed $code, mixed $version) : mixed
Parameters
- $code : mixed
- $version : mixed
Return values
mixed —removeDatabaseScript()
Removes a database update script in the history table.
protected
removeDatabaseScript(mixed $code, mixed $version, mixed $script) : mixed
Parameters
- $code : mixed
- $version : mixed
- $script : mixed
Return values
mixed —setDatabaseVersion()
Updates a plugin version in the database.
protected
setDatabaseVersion(mixed $code[, mixed $version = null ]) : mixed
Parameters
- $code : mixed
- $version : mixed = null