System\Classes\VersionManager
Overview
VersionManager manages the versions and database updates for plugins
Protected Properties
protected array $fileVersions
fileVersions cache of plugin versions as files.
protected array $databaseVersions
databaseVersions cache of database versions
protected array $databaseHistory
databaseHistory cache of database history
protected System\Classes\PluginManager $pluginManager
protected Illuminate\Console\OutputStyle $notesOutput
protected Illuminate\Console\Command $notesCommand
Public Methods
public __construct()
public __construct(): void
__construct this class
public getLatestVersion()
public getLatestVersion(string $plugin): void
getLatestVersion returns the latest version for a plugin
public getNotesCommand()
public getNotesCommand(): Illuminate\Console\Command|null
getNotesOutput returns the note command object, if available.
public getNotesOutput()
public getNotesOutput(): Illuminate\Console\OutputStyle|null
getNotesOutput returns the note output, used by command line.
public hasVersion()
public hasVersion($plugin, $version): bool
hasVersion will return true if a plugin has been registered at a supplied version
public static instance()
public static instance(): static
instance creates a new instance of this singleton
public listNewVersions()
public listNewVersions($plugin): void
listNewVersions returns a list of unapplied plugin versions
public purgePlugin()
public purgePlugin(string $pluginCode): void
purgePlugin deletes all records from the version and history tables for a plugin
public removePlugin()
public removePlugin($plugin, $toVersion = null): bool
removePlugin removes and packs down a plugin from the system. Files are left intact If the $toVersion parameter is specified, the process stops after the specified version is rolled back.
public removePluginToVersion()
public removePluginToVersion(
$plugin,
$toVersion,
$includeVersion = false
): bool
removePluginToVersion will remove the plugin version up to a specified one, you may also specify to include that version itself as part of the rollback.
public setNotesCommand()
public setNotesCommand(Illuminate\Console\Command $command): void
setNotesCommand sets the fully qualified command for writing notes.
public setNotesOutput()
public setNotesOutput(Illuminate\Console\OutputStyle $output): void
setNotesOutput sets an output stream for writing notes.
public updatePlugin()
public updatePlugin($plugin, $toVersion = null): void
updatePlugin updates a single plugin by its code or object with it's latest changes If the $toVersion parameter is specified, the process stops after the specified version is applied.
Protected Methods
protected applyDatabaseComment()
protected applyDatabaseComment($code, $version, $comment): void
applyDatabaseComment registers a database update comment in the history table
protected applyDatabaseScript()
protected applyDatabaseScript($code, $version, $script): void
applyDatabaseScript registers a database update script in the history table
protected applyPluginUpdate()
protected applyPluginUpdate($code, $version, $details): void
applyPluginUpdate applies a single version update to a plugin.
protected extractScriptsAndComments()
protected extractScriptsAndComments($details): array
extractScriptsAndComments extracts script and comments from version details
protected getDatabaseHistory()
protected getDatabaseHistory($code): void
getDatabaseHistory returns all the update history for a plugin
protected getDatabaseVersion()
protected getDatabaseVersion($code): void
getDatabaseVersion returns the latest version of a plugin from the database
protected getFileVersions()
protected getFileVersions($code): void
getFileVersions returns all versions of a plugin from its version file
protected getLatestFileVersion()
protected getLatestFileVersion($code): void
getLatestFileVersion returns the latest version of a plugin from its version file
protected getNewFileVersions()
protected getNewFileVersions($code, $version = null): void
getNewFileVersions returns any new versions from a supplied version, ie. unapplied versions
protected getUpdater()
protected getUpdater(): October\Rain\Database\Updater
getUpdater returns the updater service
protected getVersionFile()
protected getVersionFile($code): string
getVersionFile returns the absolute path to a version file for a plugin, the string is empty if no file is found or resolved
protected hasDatabaseHistory()
protected hasDatabaseHistory($code, $version, $script = null): void
hasDatabaseHistory checks if a plugin has an applied update version
protected hasVersionFile()
protected hasVersionFile($code): bool
hasVersionFile checks if a plugin has a version file
protected normalizeVersion()
protected normalizeVersion($version): string
normalizeVersion checks some versions start with v and others not
protected note()
protected note(string $message): self
note writes a note event for the migrator.
protected noteScriptException()
protected noteScriptException($ex, $updateFile): void
noteScriptException prints detailed context for a migration failure: exception class + message, SQL + bindings for QueryException, and the migration file path.
protected removeDatabaseComment()
protected removeDatabaseComment($code, $version): void
removeDatabaseComment removes a database update comment in the history table
protected removeDatabaseScript()
protected removeDatabaseScript($code, $version, $script): void
removeDatabaseScript removes a database update script in the history table
protected resetCacheForCode()
protected resetCacheForCode($code): void
resetCacheForCode will reset the cache for a specified plugin code
protected setDatabaseVersion()
protected setDatabaseVersion($code, $version = null): void
setDatabaseVersion updates a plugin version in the database, if the version is not specified then the version is reset to empty.